Hi,
I have the following linking configuration and when using deep links from push notifications, my project works great in production for Android where I can POST expo notification with data field as url: :// and I get redirected using React Navigation when the user taps on the screen but this configuration does not work on iOS.
What happens in iOS though is that I receive the push notification but tapping on it does not fire the below code. When debugging, it also looks as though getLastNotificationResponseAsync isn’t working on iOS. Is there some missing config?
const linking = {
prefixes: [prefix],
config: {
screens: {
…
},
},
async getInitialURL() {
let url = await Linking.getInitialURL()
console.log(“url from deeplink:”, url)if (url != null) { return url } // Handle URL from expo push notifications const response = await Notifications.getLastNotificationResponseAsync() console.log("responseFromPushNotification: ", response) const redirectUrl = response?.notification.request.content.data.url return redirectUrl }, subscribe(listener) { const onReceiveURL = ({ url }: { url: string }) => listener(url) // Listen to incoming links from deep linking Linking.addEventListener("url", onReceiveURL) // Listen to expo push notifications const subscription = Notifications.addNotificationResponseReceivedListener((response) => { console.log("notification response:") console.log(response) const redirectUrl = response.notification.request.content.data.url console.log("redirectUrl:") console.log(redirectUrl) listener(redirectUrl) }) return () => { // Clean up the event listeners Linking.removeEventListener("url", onReceiveURL) subscription.remove() } },
}
I’ve followed expo/packages/expo-notifications at sdk-45 · expo/expo · GitHub as I’m on SDK 45.
Any tips?
Cheers