diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index 4ff898934350814774889d70f54674554aae5aea..2162283c3c559ce6841e7d22740b7b4ed40e8700 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -514,6 +514,17 @@ 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 : + [RNNotificationsBridgeQueue sharedInstance].openedLocalNotification; + [RNNotificationsBridgeQueue sharedInstance].openedRemoteNotification = nil; + [RNNotificationsBridgeQueue sharedInstance].openedLocalNotification = 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 *