Deeplinking

To handle deep links please check the react-native documentation.

On iOS, Linking.getInitialURL might return null even when the app was started as a result of a Batch push notification with a deeplink. This is because the iOS Batch SDK opens the deep-link related to your push notification, after the app has already started.

In order to workaround this, you can use the following:

import { BatchPush } from '@batch.com/react-native-plugin';

BatchPush.getInitialURL().then((url: string | null) => {
  console.log('received initial url', url)
});

This is a replacement of Linking.getInitialURL that you can use on Android or iOS: Batch.getInitialURL first checks if Linking.getInitialURL returns something, and then if it doesn't on iOS, it calls a custom native function of this module that gets the first deeplink it has ever seen. Subsequent calls to this native function will return null to prevent a future JS reload to see an old initial URL. Because of this, you have to make sure to call this method only once in the app lifetime.

Make sure to also listen for the Linking url event in case Batch opens your deep-link after you call getInitialURL.

If you are using @react-navigation to handle your deeplinks redirects, please don't forget to follow the Third-party integrations part. You can also check our Github to find an example of implementation.

If your app handles universal links please follow the native iOS documentation to declare your associated domains. Please ensure you have at least the version 1.18 of the native iOS Batch SDK installed.