react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

how to navigate to specific screen when notification opens.

Open vyas-git opened this issue 7 years ago • 6 comments

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 ??

vyas-git avatar Jun 30 '17 05:06 vyas-git

@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.

rajaishwary avatar Aug 08 '17 16:08 rajaishwary

Hi @rajaishwary @saivyas its not work for me . its working on your side??

ranashahidbashir avatar Aug 25 '17 05:08 ranashahidbashir

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.

tolgaduzenli avatar Sep 23 '17 20:09 tolgaduzenli

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

evollu avatar Sep 25 '17 14:09 evollu

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 avatar Jul 03 '19 11:07 AhmedNj

@AhmedNj r u solve it?

anastely avatar Jul 23 '19 12:07 anastely