Open expo app and link from notification

  1. SDK Version: 42.0.0
  2. Platforms(Android/iOS/web/all): Android/iOS

Hi,
I’m trying to receive a notification and link to a screen within my app based on an id passed in via the notification. I’m currently using ReactNavigation and linking to handle this navigation while the app is in foreground (see https://reactnavigation.org/docs/navigation-container/#linking). Unfortunately, when the app is closed and I tap on the notification with the link, it will not link to the id provided by the notification. Any way I can do this? I’m currently running the app in Expo Go and my phone and in android/ios simulators.

Thanks,
Scott

Closed, or backgrounded? Or both?

You can listen to interactions with notifications in all cases (foreground, background, and killed) using Notifications.addNotificationResponseReceivedListener

Using Notifications.addNotificationResponseReceivedListener inside of the linking prop of ReactNavigation container (see Notifications - Expo Documentation), it works if app is in foreground or background. If app is killed, it doesn’t pick it up.

I tried Notifications.getLastNotificationResponseAsync() outside of the NavigationContainer and was able to get the notification. Guessing the listener in the NavigationContainer doesn’t receive the notification because it’s not created when the app starts. Any suggestions on workaround on how to navigate using id from the notification or maybe I missing something? Let me know if makes sense.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.