Catch deeplinks in React-Native

5 days ago 4
ARTICLE AD BOX

I’m currently implementing a React Native library that includes both Android and iOS native modules. One of the features of this library is sending a deep link back to the host app whenever a specific action occurs inside the SDK.

On iOS, everything works as expected — the deep link is received and handled correctly by React Native.
However, on Android, the deep link never reaches the React Native layer.

I suspect the issue is on the Android side, but I’m not sure what I’m doing wrong.


Android – How I trigger the deep link

This is the code I use inside my Android native module to launch the app with a deep link:

internal fun launch(context: Context, dataUri: Uri?) { val launchAppIntent = context.packageManager .getLaunchIntentForPackage(context.packageName) ?.apply { data = dataUri flags = FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_SINGLE_TOP or FLAG_ACTIVITY_REORDER_TO_FRONT } if (launchAppIntent != null && dataUri != null) { context.startActivity(launchAppIntent) } }

React Native – How I listen for deep links

In my test app, I listen for deep links like this:

useEffect(() => { // Handle deep link when app is cold-started Linking.getInitialURL().then((url) => { console.log("deeplink url received:", url); if (url) handleDeepLink(url); }); // Handle deep link when app is already running const subscription = Linking.addEventListener("url", (event) => { console.log("deeplink url received:", event.url); handleDeepLink(event.url); }); return () => { console.log("Removing deep link listener"); subscription?.remove(); }; }, []);

Despite this setup, Android never delivers the deep link to React Native, while iOS works perfectly.

Read Entire Article