3

I am on Android and I want to use DeepLink to open a specific screen using react navigation.

Here is my manifest:

<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>

and here is the link I use:

http://samtbook.me/test/

and I registered my deepLink like this:

  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');
    };

The poblem is When the app is not running in the background(Means dead) I click over the link and it opens the app but not navigate to intended screen but when the app is running in background it navigates

Thanks in advance

2 Answers 2

2

Use react navigation deeplinking mentioned in doc:
https://reactnavigation.org/docs/en/deep-linking.html

Sign up to request clarification or add additional context in comments.

Comments

1

Http scheme is detected as a web url just change your scheme to a custom scheme for example "myapp" and change your url to myapp://samtbook.me/test/ good luck!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.