2

i'm using this react-native-firebase and react-navigation for navigating and i can push notification from server or console successfully whether its in foreground or background but i swear the documentation is not pretty clear how to open notification and navigate to the notification screen it belongs to. these are my onMessage codes.

 firebase.messaging().onMessage((payload) => {

     if(!payload.opened_from_tray){
      firebase.messaging().createLocalNotification({
        title: payload.title,
        body: payload.body,
        show_in_foreground: true,
        icon: "ic_launcher",
        local_notification: "true",
        priority: "high",
        click_action:"ACTION",
        opened_from_tray: true,
      })
     }


  });

i'm running the version 3.2.2 of react-native-firebase

frontendkiller
  • 125
  • 2
  • 13
  • https://medium.com/react-native-training/deep-linking-your-react-native-app-d87c39a1ad5e Did you look this already? – Bright Lee Jan 18 '18 at 10:50
  • @Bright Lee thx for quick reply let me look into it – frontendkiller Jan 19 '18 at 06:03
  • @Bright Lee if understand well Deep linking is used to link ur app with incoming url from websites or external app and in that article they didn't talked about notifications I think there is how you can handle click_actions in those library such as React-native-firebase or React-native-fcm but their documentation sucks – frontendkiller Jan 19 '18 at 06:10
  • @dannykush Did you found a way to do this? – user2976753 Feb 20 '18 at 10:37

1 Answers1

3

right now i am not using createLocalNotification(), so am able to receive a notification when my app is closed using getInitialNotification(), :)

firebase.messaging().getInitialNotification()
    .then(payload => {
      console.log(payload);
      if(payload.slug != undefined){
        this.props.navigation.navigate('notification',{slug:payload.slug});
      }else{

      }
    });

i hope it solves your issue too

frontendkiller
  • 125
  • 2
  • 13
  • Hello, can you check this question please @frontendkiller https://stackoverflow.com/questions/57171787/navigate-to-screen-after-opening-a-notification – DevAS Jul 23 '19 at 22:33