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

Write listener for initial system notifications #66

Open andy9775 opened 7 years ago

andy9775 commented 7 years ago

Modify Notification.addListener('press', ...) to only register an on click listener. To determine if the application was initially opened (not in background) via a notification click create a new listener Notification.addListener('initial',...) to handle this event.

Add a new callback to addListener which is called if the app is loaded by the user and not by clicking a notification

Example usage:

Notification.addListener('press',
      () => console.log('regular press listener'));

Notification.addListener('initial',
      () => console.log('do something if app is opened with notification'),
      () => console.log('do something else if app is opened normally'));