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

port notificationIOS request permission function

parent bdf25812
...@@ -96,22 +96,16 @@ RCT_EXPORT_METHOD(requestPermissions) ...@@ -96,22 +96,16 @@ RCT_EXPORT_METHOD(requestPermissions)
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 =
[UIUserNotificationSettings settingsForTypes:(NSUInteger)types categories:nil];
[app registerUserNotificationSettings:notificationSettings];
} else { } else {
// iOS 8 or later [app registerForRemoteNotificationTypes:(NSUInteger)types];
// [END_EXCLUDE]
UIUserNotificationType allNotificationTypes =
(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