考虑这种情况。应用程序运行,并且 application:didRegisterForRemoteNotificationsWithDeviceToken: 接收到该应用程序有权接收推送通知的信息。
用户将应用置于后台,并删除应用接收设备配置通知的授权。
用户再次运行应用程序。从后台返回后,应用程序仍然认为它有权接收推送通知。此时 application:didRegisterForRemoteNotificationsWithDeviceToken: 或 application:didFailToRegisterForRemoteNotificationsWithError: 都不会收到任何信息。
有没有办法在任何给定点知道应用程序是否有权接收推送通知(从设备的通知首选项中读取某些内容)?
谢谢。
最佳答案
每次应用从后台返回时,您都可以检查[[UIApplication sharedApplication]enabledRemoteNotificationTypes]
。
参见:iOS - Check for push notification support in the app
Once I have verified that the user has it disabled is there a way to programmatically direct the user to the notification settings on the device's configuration?
对于较新的 iOS 版本,否。根据Navigate to settings screen in iphone和 iOS Launching Settings -> Restrictions URL Scheme ,您可以使用 -[[UIApplication sharedApplication] openURL:]
导航至设置屏幕,但仅限于运行 iOS 5.0 及更早版本的设备。
关于iphone - 了解应用程序是否有权实时接收推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14522246/