Navigate to screen after opening a notification?

You don't have explained what you expected.. but I think you don't want to start with that notification-screen, but with the Home-Screen.

For this, you can use the initialRouteName as second parameter for your createStackNavigator method (see example at the very bottom of this Page: https://reactnavigation.org/docs/en/stack-navigator.html)

Give it a try, and if solved, go hunt for the second issue (I prefer to solve issues Step by Step)


Best way to handle navigation on notification opening is to handle them in a splash screen. this will give you more flexibility. just check if the app is opened by notification, in componentDidMount, And navigate to the desired screen. you can use createSwitchNavigator to prevent android back button and ios gesture, from going back to the splash screen.

I think the second issue when I receive a notification "when app killed" and click to open it, it's opened very well and navigate me to "Notifications Screen" But in every time after I open the app without click to any notification it navigates me to "Notifications Screen", SO How can I remove the previous notification "remove the listener in getInitialNotification "

To solve this issue you have to save the messageId/notificationId in AsyncStorage after processing the notification and before navigating to the new screen. And just before processing the notification you can check if that notification is already processed.

the steps you have to take:

1- check if the notificationId is processed before ( this can be an AsyncStorage call).

2- if processed: clear AsyncStorage, 'cause we don't need it anymore

3- if not: add the notificationId to AsyncStorage and navigate to the new screen