У меня проблема при попытке запросить разрешение на удаленные уведомления.
Он безупречно работает на iOS 10, но когда я пытаюсь сделать это на устройстве iOS 9, он не показывает никаких предупреждений, а метод делегата UIApplication «application:didRegisterForRemoteNotificationsWithDeviceToken:» не вызывается. Ни "неудачный" метод.
Я тестирую только на реальных устройствах, а не на симуляторе. Код, который я сейчас использую для запроса разрешения, следующий:
-(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];
}
}
Кто-нибудь понял?