Setting up deep linking from push notifications in your ReactNative app
Support linking to your in-app content directly from push notifications
Enabling deep linking in ReactNative is achieved using the Linking module as described in the official ReactNative guide.
In order to link to your content from push notifications, an extra step is needed.
Linking module exposes a
getInitialURL method that returns a
Promise to the deep link URL that launched the app. This method does not take into account push notifications and must be complemented like this:
// Replace this: const initialUrl = await Linking.getInitialURL(); // With this: const initialUrl = await Linking.getInitialURL() || await WonderPush.getInitialURL();
If you are using a router, like React Navigation, the extra step is identical: just make sure you fall back to
await WonderPush.getInitialURLwherever you call
This is typically done in the
getInitialURLmethod of your
linkingoptions, as shown in the React Navigation third-party integration guide
Updated about 1 year ago