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.

The 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.getInitialURL wherever you call await Linking.getInitialURL().

This is typically done in the getInitialURL method of your linking options, as shown in the React Navigation third-party integration guide