0

I am using react-native-fcm for notification and successfully receiving notification. My problem is when i click on that notification it must navigate to specific screen.

I have a stack navigator with home and alerts. i am writing my code in login which much navigate to alerts.

FCM.on(FCMEvent.Notification, async (notif) => {
if (notificationData.message === 'New alert generated.') {

        FCM.presentLocalNotification({
            vibrate: 500,
            title: 'title',
            priority: "high",
            show_in_foreground: true,
            group: 'test',
            large_icon: "ic_launcher",
            icon: "ic_launcher",
        });
    }
}

Here im using presentLocalNotification() to show notification. where should i use this.props.navigation.navigate('alerts');

HungrySoul
  • 1,151
  • 2
  • 17
  • 31

1 Answers1

-1
FCM.on(FCMEvent.Notification, async (notif) => {
 if(notif){
  if(notif.opened_from_tray && notif.local_notification) {
     // Handle navigation here
     this.props.navigation.navigate('alerts');
   } else {
     FCM.presentLocalNotification({
            vibrate: 500,
            title: 'title',
            priority: "high",
            show_in_foreground: true,
            group: 'test',
            large_icon: "ic_launcher",
            icon: "ic_launcher",
        });
   }
 }
}
Kranthi
  • 1,040
  • 8
  • 15