【问题标题】:RCTLinkingManager : Listening to application urls in iOSRCTLinkingManager : 在 iOS 中监听应用程序 url
【发布时间】:2016-08-16 12:08:05
【问题描述】:

感谢这篇精彩的文章:http://blog.lum.pe/listening-to-application-urls-in-react-native/

我能够使深层链接和指向应用程序的链接正常工作。每当用户单击以我的自定义 url 开头的任何 url 时,应用程序都会打开。但问题是,如果打开并在后台,我可以访问 URL(打开应用程序,从中获取一些值。就像 url://username:123) 但是如果应用程序关闭,并且用户点击链接,应用程序将被打开,但我无法再访问该 url。

有什么解决办法吗?

【问题讨论】:

    标签: javascript ios xcode reactjs react-native


    【解决方案1】:

    我刚刚写了关于 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);
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-30
      • 1970-01-01
      • 2011-11-27
      • 2018-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多