zetavg / react-native-system-notification

Android system notifications for React Native. Supports push notifications with GCM integrated.
https://www.npmjs.com/package/react-native-system-notification
244 stars 102 forks source link

Initial action and payload on addListener #18

Open lukefanning opened 8 years ago

lukefanning commented 8 years ago

@Neson It seems to be the case that after creating a notification with an action and payload while the app is in the background, the notification listener function is repeatedly being invoked on calling addListener.

The first time you do want that behaviour as it has come from the notification that was just pressed/clicked. However on returning to that screen within the app it then calls the listener function again. I am calling addListener in componentWillMount() on a particular screen.

Looking at your code it is clear that this is happening because this.module.sysInitialNotificationPayload (and the action) is still set even after it has already been used (i.e. line 79 listener(event)).

zetavg commented 8 years ago

Yes, it is. I'm still figuring out a better way to solve this problem. Maybe by adding an variable in the Notification object to log if the first registration. Or I'll go see how FB has done this on RN iOS. :smile: