Friday, 15 January 2021

How to use React Navigation universal links with path parameters on Android?

I have the following domain: https://demoproject.com

I would like to link all URL-s with /demo path parameter with my React Native application on Android so that for example URL https://demoproject.com/demo?a=1&b=2 will be linked, but any other URL with same domain, but different path parameters will be excluded.

Right now I am using React Navigation 5 like this:

const linking = {
    prefixes: ['https://demoproject.com'],
    config: {
      DemoScreen: {
          path: '/demo/*'
      }
    }
};
<NavigationContainer linking={linking}>

AndroidManifest.xml

<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="https" />
      <data android:host="demoproject.com" />
</intent-filter>

Linking itself is working fine, but the problem is that all URL-s with prefix https://demoproject.com are being linked while I only want URL-s with /demo path parameter to be linked.

I have tried:

  • <data android:host="demoproject.com/demo" /> - none of the URL-s are linked
  • prefixes: ['https://demoproject.com/demo'] - all of the URL-s with https://demoproject.com domain are linked

Any ideas how to solve this or what am I doing wrong here?



from How to use React Navigation universal links with path parameters on Android?

No comments:

Post a Comment