Commit 971ab0b7 authored by Libin Lu's avatar Libin Lu

port notificationIOS request permission function

parent bdf25812
...@@ -92,26 +92,20 @@ RCT_REMAP_METHOD(getFCMToken, ...@@ -92,26 +92,20 @@ RCT_REMAP_METHOD(getFCMToken,
RCT_EXPORT_METHOD(requestPermissions) RCT_EXPORT_METHOD(requestPermissions)
{ {
if (RCTRunningInAppExtension()) { if (RCTRunningInAppExtension()) {
return; return;
} }
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
// iOS 7.1 or earlier
UIRemoteNotificationType allNotificationTypes = UIApplication *app = RCTSharedApplication();
(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge); if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:allNotificationTypes]; UIUserNotificationSettings *notificationSettings =
} else { [UIUserNotificationSettings settingsForTypes:(NSUInteger)types categories:nil];
// iOS 8 or later [app registerUserNotificationSettings:notificationSettings];
// [END_EXCLUDE] } else {
UIUserNotificationType allNotificationTypes = [app registerForRemoteNotificationTypes:(NSUInteger)types];
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); }
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
} }
- (void)handleRemoteNotificationReceived:(NSNotification *)notification - (void)handleRemoteNotificationReceived:(NSNotification *)notification
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment