evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 681 forks source link

this.notificationListner not getting called. #1066

Open avoidchanges opened 5 years ago

avoidchanges commented 5 years ago
componentDidMount() {

FCM.requestPermissions({badge: true, sound: true, alert: true}).then(()=>console.log('granted')).catch(()=>console.log('notification permission rejected'));

FCM.getInitialNotification().then(notif => {
    console.log("INITIAL NOTIFICATION", notif)
  });

  this.notificationListner = FCM.on(FCMEvent.Notification, notif => {
    console.log("Notification", notif);
    if(notif.local_notification){
      console.log('LOG GOLD');
      return;
    }
    if(notif.opened_from_tray){
      console.log('LOG SILVER');
      return;
    }
  });
}

This is my code. It seems I'cant make this.notificationListner to work. Console.log not getting called. getinitialnotification works fine. Please help.

margaridaDinis commented 5 years ago

Are you calling this.notificationListner anywhere?

fukemy commented 1 year ago

i got same problem, i got this function triggered when get notification + app killed, remoteMessage = null