javascript - RCT链接管理器 : Listening to application urls in iOS

标签 javascript ios xcode reactjs react-native

感谢这篇精彩的文章: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/

相关文章:

javascript - 如何用jquery计数器实现一个简单的错误

javascript - 全局 Javascript 链接处理程序

ios - 如何在 iOS Objective-C 中集成 'Sign in with Apple' 流?

ios - 忽略 ssl 认证 MKNetworkKit

ios - UITabbar背景图片iPhone 6问题

ios - 如何设置从页面控件指示器到 View 的约束

javascript - 怎么做?

javascript - 如何在jquery中只执行一次action?

cocoa - 文本字段渲染

iphone - UIAlertView 多个带有文本的按钮