本地通知是否需要iOS上的用户权限?

RPM*_*RPM 21 notifications local uilocalnotification swift

我在我的应用程序中使用UILocalNotification来安排通知.通知工作正常,并在我需要时显示.我没有这个问题.我没有做任何远程/推送通知.

令我疑惑的是,我从未在几个应用程序中看到过您通常看到的推送通知的着名权限对话框.我甚至重置了我的设备并运行了我的应用程序 这仍然没有导致权限对话框出现.

如果您的应用仅使用本地通知,或者我没有实现某些实际导致应用请求此权限的方法,是否会显示此权限对话框?

我知道我可以在应用程序启动后实现我自己的对话框,要求用户提供此权限,但我希望Apple能够解决这个问题,特别是因为它在设置应用程序中对待远程和本地通知.

luv*_*ere 17

是的,在iOS8中,本地通知确实需要权限.

该文档registerUserNotificationSettings:规定

如果您的应用在后台显示警报,播放声音或标记其图标,则必须在启动周期内调用此方法以请求以这些方式提醒用户的权限.通常,如果您的应用使用本地或推送通知来提醒用户注意涉及您应用的新信息,则会发出此请求.

建议您在安排任何本地通知或使用推送通知服务注册之前调用此方法.


RPM*_*RPM 11

看起来本地通知不需要任何用户权限."权限"对话框仅显示"推送通知".我可以在没有任何用户许可的情况下安排/取消本地通知.


Ted*_*Ted 6

注意:这包括推送通知/远程通知

当在运行时使用registerUserNotificationSettings:API时,在iOS7或iOS8测试中使用Xcode6时.

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {  
    UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];  
    [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];  
    [[UIApplication sharedApplication] registerForRemoteNotifications];  
} else {  
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];  
}  
Run Code Online (Sandbox Code Playgroud)

感谢http://corinnekrych.blogspot.ae/2014/07/how-to-support-push-notification-for.html