|
@@ -79,9 +79,24 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
|
|
self.window.rootViewController = rootViewController;
|
|
self.window.rootViewController = rootViewController;
|
|
|
[self.window makeKeyAndVisible];
|
|
[self.window makeKeyAndVisible];
|
|
|
[super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
[super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
|
|
|
+
|
|
|
|
|
+ [self registerForPushNotifications];
|
|
|
return YES;
|
|
return YES;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)registerForPushNotifications {
|
|
|
|
|
+ UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
|
|
|
+ [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error) {
|
|
|
|
|
+ if (granted) {
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [[UIApplication sharedApplication] registerForRemoteNotifications];
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 用户拒绝通知或发生错误
|
|
|
|
|
+ }
|
|
|
|
|
+ }];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
|
|
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
|
|
|
///
|
|
///
|
|
|
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
|
|
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
|