diff --git a/docs/advancedIos.md b/docs/advancedIos.md index e58fc164e9fc414363013e848b233116d060a40f..27f69ce15383f6279500a871f1854a0be6d2e547 100644 --- a/docs/advancedIos.md +++ b/docs/advancedIos.md @@ -91,11 +91,20 @@ After [preparing your app to receive VoIP push notifications](https://developer. #import ``` +### Listen to PushKit notifications +On receiving PushKit notification, a `pushKitNotificationReceived` event will be fired with the notification payload. + +```objective-c +#import "RNNotifications.h" +#import +``` + In your ReactNative code, add event handler for `pushKitRegistered` event and call to `registerPushKit()`: ```javascript constructor() { - NotificationsIOS.addEventListener('pushKitRegistered', this.onPushKitRegistered.bind(this)); + NotificationsIOS.addEventListener('pushKitRegistered', this.onPushKitRegistered.bind(this)); + NotificationsIOS.addEventListener('pushKitNotificationReceived', this.onPushKitNotificationReceived.bind(this)); NotificationsIOS.registerPushKit(); } @@ -103,6 +112,10 @@ onPushKitRegistered(deviceToken) { console.log("PushKit Token Received: " + deviceToken); } +onPushKitNotificationReceived(notification) { + console.log('PushKit notification Received: ' + JSON.stringify(notification)); +} + componentWillUnmount() { // Don't forget to remove the event listeners to prevent memory leaks! NotificationsIOS.removeEventListener('pushKitRegistered', onPushKitRegistered(this));