Невозможно увидеть параметр MyAppNotificationSettings в приложении «Настройки» - PullRequest
2 голосов
/ 04 февраля 2020
   UNUserNotificationCenter *notificaitnCenter = [UNUserNotificationCenter currentNotificationCenter];
    [notificaitnCenter requestAuthorizationWithOptions:UNAuthorizationOptionBadge | UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionProvidesAppNotificationSettings completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (granted) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [[UIApplication sharedApplication] registerForRemoteNotifications];

            });

        }
    }];

После реализации этого фрагмента кода я также не могу увидеть опцию настроек уведомлений.

1 Ответ

1 голос
/ 05 февраля 2020
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")){
    UNUserNotificationCenter *notifiCenter = [UNUserNotificationCenter currentNotificationCenter];
    notifiCenter.delegate = self;
    [notifiCenter requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
        if( !error ){

            dispatch_async(dispatch_get_main_queue(), ^{
                [[UIApplication sharedApplication] registerForRemoteNotifications];
            });

        }
    }];

}
else
{
    UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
}

Может быть ios версия не поддерживает Попробуйте этот код

...