react-native-fcm
react-native-fcm copied to clipboard
how to navigate to specific screen when notification opens.
Hi i am using react navigation to navigate screens.I am successfully sending notifications from firebase notifications panel with additional data.
Now i don't know how to get that data and navigate to specific screen dynamically.
I am passing screen as key and values are like home,about.
navigate.navigate(val) is this possible ??
@saivyas are you using firebase-admin to send remote notification ?
If Yes, you can send the following payload. const payload = { "notification": { "title": "title", "body": "message", "click_action": "fcm.ACTION.HELLO", }, "data": { "additional_data": "data1", "additional_data2": "data2" } }
then, you can navigate the screen based on additional data. It can be screen name or screen ID.
Hope the information help you.
Hi @rajaishwary @saivyas its not work for me . its working on your side??
We have also same problem for ios and android. Still we couldnt find how can we redirect or navigate user to the custom(specific page) after user click(open) the notification.
In README file I couldnt find any solution for IOS. For android, I couldnt understand how should I change the "fcm.ACTION.HELLO".
@evollu replace "fcm.ACTION.HELLO" by the click_action you want to match this explanation is not enough, can you give more specific explanation or code snippet ?
Thanks for your time and work.
you can say in payload
const payload = {
"notification": {
"title": "title",
"body": "message"
},
"data": {
"screen": "[your target screen]"
}
}
then in notification handler say
if(notification.screen === 'somescreen'){
then Navigate.nav('somescreen')
}
"fcm.ACTION.HELLO" is equivelent of iOS's click_action: "fcm.ACTION.HELLO"
which to pass extra data in old days. you shouldn't need it anymore in most cases
Hello, plz i have the same issue, i set up the push notifications code, i receive successfully the notif in my app, but after that i dont know how to navigate to the detail of the notif , and wher must i place the code of push notif ( until now, i placed it in app.js )
@AhmedNj r u solve it?