From 5f228aadc605500797cd7275654a9d835fcede34 Mon Sep 17 00:00:00 2001 From: yogevbd Date: Tue, 9 Jul 2019 14:59:04 +0300 Subject: [PATCH] Update pushKit docs --- docs/advancedIos.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/advancedIos.md b/docs/advancedIos.md index e58fc16..27f69ce 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)); -- 2.26.2