DeepLinking 工作但没有使用反应导航导航到预期屏幕

DeepLinking work but no navigate to Intended Screen using react navigation

我在 Android,我想使用 DeepLink 使用 React 导航打开特定屏幕。

这是我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.samtbook">

<application
        android:name=".MainApplication"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:allowBackup="false"
        android:theme="@style/AppTheme"
        android:supportsRtl="false"
        android:usesCleartextTraffic="true"
>
    <activity
            android:launchMode="singleTask"
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="http" android:host="samtbook.me"/>
        </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
    <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="API_KET"/> // HIDDEN
</application>

这是我使用的link:

http://samtbook.me/test/

我这样注册了我的深度链接:

  componentDidMount() {
    Linking.addEventListener('url', this.handleOpenURL);
    }
    componentWillUnmount() {
    Linking.removeEventListener('url', this.handleOpenURL);
    }

    handleOpenURL = (event) => {
    this.navigate(event.url);
    };
    navigate = (url) => {
      this.props.navigation.navigate('TestScreen');
    };

问题是当应用程序不在后台时 运行(意味着死了) 我点击 link 并打开应用程序但未导航到预期屏幕 但是当应用程序在后台 运行 时,它会导航

提前致谢

HTTP 方案被检测为 Web url 只需将您的方案更改为自定义方案,例如 "myapp" 并将您的 url 更改为 myapp://samtbook。me/test/ 祝你好运!

使用文档中提到的 React 导航深层链接:
https://reactnavigation.org/docs/en/deep-linking.html