不是在 iOS 中请求通知权限,而是将 "notification permission settings" 添加到设备设置中?

Not to ask for permission for notifications in iOS but add "notification permission settings" into device settings?

我不想显示 "ask permission for notifications" 对话框,只是将我的应用程序的禁用设置添加到设备设置中。

问题是如果应用程序不请求这些权限,则相关设置根本不会出现在设备设置中。

我调用权限对话框的代码:

UIUserNotificationType types = UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

你能帮忙解决这个问题吗?目前我只使用本地通知

根据 Apple 文档,您必须首先请求用户许可。因此,为了进行设置,您必须至少询问用户一次。

我在我的应用程序中使用它来接收推送通知:-

// Let the device know we want to receive push notifications
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    {
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }
    else
    {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
    }