不要求iOS中的通知权限,而是添加"通知权限设置"进入设备设置?

时间:2016-08-11 07:12:23

标签: ios permissions notifications uilocalnotification localnotification

我不想显示"要求获得通知许可"对话框,只需将我的应用程序的禁用设置添加到设备设置中。

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

我的呼叫权限对话框代码:

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

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

2 个答案:

答案 0 :(得分:1)

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

enter image description here

答案 1 :(得分:-1)

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

// 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)];
    }