Deep Linking does nothing on android React Native

376 views Asked by At

I am trying to acheive the deep linking functionality in React Native, i have followed the official docs from React Native, also follow documentation from React Navigation. I have changed my AndroidManifest.xml file and added the intent filters as per documentation as follow:

    <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:host="app" android:scheme="demo"/>
</intent-filter>

also changed the android:lunchMode to android:launchMode="singleTask".

when i install the app using npx react-native android and app successfully install on the user device. After that i run the adb command to check the deep linking and i get below response:

$ adb shell am start -W -a android.intent.action.VIEW -d "demo://app/chat/123" com.rndemo
Starting: Intent { act=android.intent.action.VIEW dat=app://whatsupp/chat/123 pkg=com.whatsupfire }
Warning: Activity not started, intent has been delivered to currently running top-most instance.
Status: ok
Activity: com.rndemo/.MainActivity
ThisTime: 0
TotalTime: 0
WaitTime: 19
Complete

Here are my linking configs:

const config = {
  screens: {
    Chat: {
      screen: {
        ChatStack: {
          path: 'chat/:id',
          parse: {
            toId: (id) => `${id}`,
          },
        },
      },
    },
  },
};

const linking = {
  prefixes: ['demo://', 'demo://app'],
  config: config,
};

I am using React Navigation V5, I am using linking in the App.js in NavigatorContainer, the important thing to mention here is that i am using authentication flow using the official docs of React Navigation and the chat is nested in navigator, but i also tried to access demo://app and the adb shell returns the same response as above.

1

There are 1 answers

1
Polina On

Add linking prop to NavigationContainer:

<NavigationContainer linking={linking} >