I have a problem when trying to ask permission for remote notifications.
It works flawlessly on iOS 10 but when I try to do it on an iOS 9 device it doesn't show any alert and the UIApplication delegate method "application:didRegisterForRemoteNotificationsWithDeviceToken:" isn't called. Neither the "failed" method.
I'm only testing on real devices, not simulator. The code I currently use for asking permission is the following:
-(void)requestPushPermissions {
NSLog(@"Starting register for remote Notification");
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
NSLog(@"Got a yes!");
}
else {
NSLog(@"Got a no...");
}
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else {
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}
Anybody got a clue?