diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index dd281e6e5806f6d2e891731d53b22a9726eea48a..9c61ca876b8698e9d1b0b552c97c037536403894 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 8c295a43286a89057ebe386f1744c3d39309dc6c..7a167c90f95810faae06d398f128f5d557c6d63d 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 *