Deep link Native Android app with React Native app

Sathyapriya S
Spritle Software
Published in
2 min readDec 7, 2017

We are working with two different apps, one written in Android java and another written in React Native. One of the feature requires us to invoke React Native app from Native Android app and then re-direct to specific screen in it.

We have accomplished this feature using Deep linking with help of scheme and host. In this article, we’ll share about how the way we handled in both app.

To receive an intent from external app, we need to add an intent filter that contains these elements and attribute values in your manifest file

To start, you need to pick an Activity within your app that you’d like to open when the URI scheme is triggered and register an intent filter for it.

Scheme must be unique. If it overlaps with another app’s URI scheme, the user will see an Android chooser when clicking on the link.

Handling deep link in native Android app

Call the getData() and getAction() methods to retrieve the data and action associated with the incoming Intent.

Handling deep link in React native app

  • In react native , there is more eloquent way to implement this through Linking API. With the help of getInitialURL() and listener methods, We can handle it as shown below:
  • getInitialURL() - If the app is launched by external link, then this method will get executed.
  • Linking.addEventListener('url',handler) - A listener method to receive url from the external app where we already embedded scheme and host.
  • Here we receive and check the url from external native app, based on this url we navigate to different screen in React Native app.

To set the deep link in Android App

Action : all Intents are called as View action — ACTION_View

URI : intents use URI encoded strings that specify a desired action along with some data which to perform an action.

One more thing : We can also use adb command to test…

$ adb shell am start
-W -a android.intent.action.VIEW
-d "link://exampleurl" com.shooter

This might be extremely easy for implementing Deep liking in React Native. Thanks to my friend Prabakaran for helping me to get the React Native app part done.

We are people from Spritle and we ❤ to build awesome apps using Rails, Node JS, Android, Swift, React Native and so on. Visit spritle.com to hire our kick-ass team that can bring your ideas to reality.

--

--