Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ PushNotification.configure({
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.log( 'NOTIFICATION:', notification );

// process the notification

// required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
notification.finish(PushNotificationIOS.FetchResult.NoData);
},

// ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ Notifications._onNotification = function(data, isFromBackground = null) {
data: data.getData(),
badge: data.getBadgeCount(),
alert: data.getAlert(),
sound: data.getSound()
sound: data.getSound(),
finish: (res) => data.finish(res)
});
} else {
var notificationData = {
foreground: ! isFromBackground,
finish: () => {},
...data
};

Expand Down