From 5c796bf70ecf610c6f44ca3311ef53bfa6c1186f Mon Sep 17 00:00:00 2001 From: Yedidya Kennard Date: Sun, 25 Feb 2018 15:51:20 +0200 Subject: [PATCH] getInitialNotification implemented on iOS --- RNNotifications/RNNotifications.m | 8 ++++++++ index.ios.js | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index dd281e6..9c61ca8 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -513,6 +513,14 @@ RCT_EXPORT_METHOD(requestPermissionsWithCategories:(NSArray *)json) [RNNotifications requestPermissionsWithCategories:categories]; } +RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) +{ + NSDictionary * notification = nil; + notification = [RNNotificationsBridgeQueue sharedInstance].openedRemoteNotification; + [RNNotificationsBridgeQueue sharedInstance].openedRemoteNotification = nil; + resolve(notification); +} + RCT_EXPORT_METHOD(log:(NSString *)message) { NSLog(message); diff --git a/index.ios.js b/index.ios.js index 8c295a4..7a167c9 100644 --- a/index.ios.js +++ b/index.ios.js @@ -180,6 +180,15 @@ export default class NotificationsIOS { NativeRNNotifications.log(message); } + static async getInitialNotification() { + const notification = await NativeRNNotifications.getInitialNotification(); + if (notification) { + return new IOSNotification(notification); + } else { + return undefined; + } + } + /** * Presenting local notification * -- 2.26.2