react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

onNotification not called for localNotifications (unless tapped)

Open Faolain opened this issue 7 years ago • 13 comments

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,
  });
};

Faolain avatar Mar 23 '19 18:03 Faolain

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

polsson12 avatar Apr 07 '19 17:04 polsson12

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.

wickstjo avatar Apr 13 '19 19:04 wickstjo

Same issue.

NikhilP99 avatar Jun 26 '19 06:06 NikhilP99

Same issue, does anyone have a fix ?

ThalKod avatar Jul 09 '19 18:07 ThalKod

Same issue

liplylie avatar Jul 21 '19 20:07 liplylie

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

AfrazHussain avatar Aug 24 '19 19:08 AfrazHussain

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

ThalKod avatar Aug 24 '19 21:08 ThalKod

Same issue here.

rplusq avatar Aug 27 '19 04:08 rplusq

Any solution here?

Adr1ann avatar Jan 08 '20 08:01 Adr1ann

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

xaviergerard avatar Jan 10 '20 18:01 xaviergerard

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

Sanan4li avatar Feb 01 '20 15:02 Sanan4li

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

indigomelody avatar Mar 30 '20 13:03 indigomelody

same here, any solution for this?

abdymm avatar Feb 18 '21 04:02 abdymm