来自其他应用程序的 React Native 深度链接

React Native deep linking from other app

我们的应用程序应该可以在 company://upload 上找到。我创建了 itent-filter:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="company"
    android:host="upload" />
</intent-filter>

正在打开应用程序,但在 react-native 中我无法捕捉到 url。我的实施:

componentWillMount() {
  Linking
    .getInitialURL()
    .then(event => this.handleOpenURL(event))
    .catch(console.error);
  Linking.addEventListener('url', this.handleOpenURL);
  this.props.loadCredentials();
}

handleOpenURL(event) {
  console.log(event);
  switch (event.url) {
    case `${Config.APP_SCHEMA}upload`:
      Actions.Upload();
      break;
    default:
      Actions.Home();
  }
}

版本:

我写了一个测试深层链接的脚本:

adb shell am start -W -a android.intent.action.VIEW -d "company://" com.companyapps/.MainActivity

深层链接是正确的,问题出在我的应用程序的 Java 部分。