zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.76k stars 2.05k forks source link

onNotification not called for localNotifications (unless tapped) #1024

Open Faolain opened 5 years ago

Faolain commented 5 years ago

The onNotification callback only ever fires when receiving remote Notifications(in foreground) and not when receiving local Notifications(in foreground or background). I can make the onNotification trigger by tapping the localNotification which shows up and opening it but I need it to fire without opening as I have some logic which needs this. Has anyone else experienced this? Should localNotifications trigger the onNotification callback? If so why do remote(fcm) notifications trigger it but not local? Any help is greatly appreciated. To be clear the notifications all appear just onNotification is not being called for localNotifications.

Versions

Android 5 and Android 6
"react-native": "0.57.0"
"react-native-push-notification": "^3.1.2"

Push Notification Configuration


  PushNotification.configure({
    onRegister({ token, os }) {
      // process token
      store.dispatch(registerPushToken({ token, os }));
    },

    onNotification(notification) {
      console.log(notification)
    },

    // ANDROID ONLY: GCM or FCM Sender ID (product_number) (optional -
    // not required for local notifications, but is need to receive remote push notifications)
    senderID: ''xxx",

    permissions: {
      alert: true,
      badge: true,
      sound: true,
    },
    popInitialNotification: false,
    requestPermissions: false,
  });
};
polsson12 commented 5 years ago

I'm facing the same issue, have you been able to make any progess on this?

wickstjo commented 5 years ago

Same issue. I want to pass the notification data through a function before prompting it, but I can't find a way to listen for a trigger and it would make sense for onNotification method to be able to do that.

NikhilP99 commented 5 years ago

Same issue.

ThalKod commented 5 years ago

Same issue, does anyone have a fix ?

liplylie commented 5 years ago

Same issue

AfrazHussain commented 5 years ago

Having the same issue here. Did anyone manage to figure this out?

ThalKod commented 5 years ago

@AfrazHussain Yes, but by switching to react-native-firebase using the Notifications module.

rplusq commented 5 years ago

Same issue here.

Adr1ann commented 4 years ago

Any solution here?

xaviergerard commented 4 years ago

Same issue for me. Who's got a solution?

Sanan4li commented 4 years ago

same here... I want to open a specific screen when user clicks on action but can't find a way to do that

indigomelody commented 4 years ago

Same here! Any help on this at all would be really appreciated!

abdymm commented 3 years ago

same here, any solution for this?