Search code examples
react-nativedeep-linkingreact-native-linking

How do I open the deep link in mobile browser rather than mobile app in react native


What I am trying to do is opening a deep link in mobile browse (Not in app). Deeplinking is all set up, all the links with specific domains are opening/navigating into app opened from any where else. Now here is a scenario that there are some particular links with same domain (I set up deeplinking for), I want to open that in browser because I don't have any view to show for that link in my app so I want them open in browser.

I have identified the links but when I opened these links via Linking.openUrl it navigates me to the app.

  if (lowerUrl.includes(PostType.NO_DEEP_LINK)) {
  Linking.openURL(lowerUrl);
  return null;
}

Is there any method I can specify the Linking method to open url in mobile browser not in app although the url has a same domain that is setup for deep linkg.


Solution

  • Solution 1#

    The best possible solution for that can be using android:pathPattern in android manifest. Basically you have to provide path pattern (a sort regex) to match the valid links.

    Documentation for that can be found here. https://developer.android.com/guide/topics/manifest/data-element

    Solution # 2

    One has to make RN Native Module and instead Linking.openURL(lowerUrl) to handle this kind of scenario.

    To make browser native module one can take help from here. This solution doesn't work with devices which lacks google play services like Kindle Fire, etc