感谢这篇精彩的文章:http://blog.lum.pe/listening-to-application-urls-in-react-native/
我能够对应用程序进行深层链接和链接。每当用户点击以我的自定义网址开头的任何网址时,应用程序就会打开。但问题是,如果打开并在后台,我可以访问 URL(打开应用程序,从中获取一些值。就像 url://username:123) 但是如果应用程序关闭,并且用户单击链接,应用程序将打开,但我无法再访问该 url。
有什么解决办法吗?
最佳答案
我刚刚写了关于 iOS 中的通用链接和 Android 深度链接的文章。
https://github.com/parkerdan/React-Native-Rails-Universal-Linking
我的猜测是您没有通过处理应用程序关闭情况的 Linking.getInitialURL()
获取初始 URL。
componentDidMount(){
// this handles the case where the app is closed and is launched via Universal Linking.
Linking.getInitialURL()
.then((url) => {
if (url) {
// Alert.alert('GET INIT URL','initial url ' + url)
this.resetStackToProperRoute(url)
}
})
.catch((e) => {})
// This listener handles the case where the app is woken up from the Universal or Deep Linking
Linking.addEventListener('url', this.appWokeUp);
}
关于javascript - RCT链接管理器 : Listening to application urls in iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38974569/