//You can send data with the notification in this format
{
"to" : "FCM_token",
"collapse_key" : "type_a",
"notification" : {
"body" : "Testing",
"title": "Test Title"
},
"data" : {
"name" : "xyz"
}
}
//Now you can get data in listener
const notificationOpen = await firebase.notifications().getInitialNotification();
if (notificationOpen) {
let {name} = notificationOpen.notification._data;
console.log("Notification data - ", name);
setInitialRoute(name);
}
//Now to declare state variable and change the initialRoute of the navigator....
const [initialRoute, setInitialRoute] = useState('ABC');
setInitialRoute(name); // in the notification listener
//Now use in Navigation container
<Stack.Navigator initialRouteName={initialRoute}>
</Stack.Navigator>