【问题标题】:Unable to see the MyAppNotificationSettings option in Settings Application在设置应用程序中看不到 MyAppNotificationSettings 选项
【发布时间】:2020-05-20 07:45:48
【问题描述】:
   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];

            });

        }
    }];

在实现这个 sn-p 代码后,我也看不到通知设置选项。

【问题讨论】:

  • 您是否在项目Signing & Capabilities 配置中添加了推送通知功能?
  • 是的,我已启用它。

标签: ios objective-c xcode push-notification unusernotification


【解决方案1】:
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版本不支持试试这段代码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-30
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    相关资源
    最近更新 更多