mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
add example for capturing initial notification in push notification manager (#42687)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42687 Changelog: [Internal] adding an example for if you want to use `getInitialNotification`. Reviewed By: ingridwang Differential Revision: D52931618 fbshipit-source-id: 7552c358e5bc98228b7ae74ea1adf450f7b075e6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
75e6137add
commit
cc147ceb79
@@ -198,6 +198,7 @@ static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabri
|
||||
}
|
||||
|
||||
#pragma mark - UISceneDelegate
|
||||
|
||||
- (void)windowScene:(UIWindowScene *)windowScene
|
||||
didUpdateCoordinateSpace:(id<UICoordinateSpace>)previousCoordinateSpace
|
||||
interfaceOrientation:(UIInterfaceOrientation)previousInterfaceOrientation
|
||||
@@ -207,6 +208,7 @@ static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabri
|
||||
}
|
||||
|
||||
#pragma mark - RCTCxxBridgeDelegate
|
||||
|
||||
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
||||
{
|
||||
_runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));
|
||||
|
||||
@@ -116,12 +116,20 @@ static NSString *kBundlePath = @"js/RNTesterApp.ios";
|
||||
|
||||
// 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]) {
|
||||
// This can be retrieved with getInitialNotification.
|
||||
[RCTPushNotificationManager setInitialNotification:notification];
|
||||
}
|
||||
|
||||
[RCTPushNotificationManager didReceiveNotification:notification];
|
||||
completionHandler();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user