【问题标题】:React-Native: Passing data when opening the app from a browserReact-Native:从浏览器打开应用程序时传递数据
【发布时间】:2017-04-21 08:50:33
【问题描述】:

如果用户点击手机上的链接,如果安装了移动应用程序,我正在尝试处理该链接。我想将浏览器中的 url 传递给应用程序并在 web 视图中打开它。

例如,如果单击“myapp://something?=stringParam”。这在 React-Native 中可行吗?如果是,我如何读取发送的数据?

也许是来自链接模块的 getInitialURL?

【问题讨论】:

    标签: android ios reactjs react-native


    【解决方案1】:

    是的,您可以使用 Linking API 做到这一点。

    componentDidMount() {
      const url = Linking.getInitialURL()
      .then((url) => {
        if (url) {
          console.log('Initial url is: ' + url)
        }
      }).catch(err => console.error('An error occurred ', err))
    }
    

    要在 Android 上启用它,您必须先关注 these steps

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 2018-12-17
      • 1970-01-01
      • 2011-03-20
      • 2019-01-01
      • 1970-01-01
      • 2016-06-02
      相关资源
      最近更新 更多