diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index 8b811ab73e58dd..41992d06c2bcd6 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -198,6 +198,7 @@ - (BOOL)runtimeSchedulerEnabled } #pragma mark - UISceneDelegate + - (void)windowScene:(UIWindowScene *)windowScene didUpdateCoordinateSpace:(id)previousCoordinateSpace interfaceOrientation:(UIInterfaceOrientation)previousInterfaceOrientation @@ -207,6 +208,7 @@ - (void)windowScene:(UIWindowScene *)windowScene } #pragma mark - RCTCxxBridgeDelegate + - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge { _runtimeScheduler = std::make_shared(RCTRuntimeExecutorFromBridge(bridge)); diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index d0d725da6df193..9a4cb52cf272f4 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -9,6 +9,7 @@ #import +#import #import #import #import @@ -116,12 +117,22 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center // Required for the remoteNotificationReceived and localNotificationReceived events // Called when a notification is tapped from background. (Foreground notification will not be shown per -// the presentation option selected above.) +// the presentation option selected above). - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { - [RCTPushNotificationManager didReceiveNotification:response.notification]; + UNNotification *notification = response.notification; + + // This condition will be true if tapping the notification launched the app. + if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) { + RCTPushNotificationManager *pushNotificationManager = [self.bridge moduleForName:@"PushNotificationManager" + lazilyLoadIfNecessary:YES]; + // This can be retrieved with getInitialNotification. + pushNotificationManager.initialNotification = notification; + } + + [RCTPushNotificationManager didReceiveNotification:notification]; completionHandler(); }