ios – 延迟推送通知并检查用户是否启用了它

ios – 延迟推送通知并检查用户是否启用了它,第1张

概述我开发了一个应用程序,它围绕推送通知构建.仅当用户到达注册过程的某个点时,应用才会请求通知权限.我已经设法做了以下事情: >该应用程序维护一个NSUserDefaults变量,该变量指示是否需要在启动时注册推送(默认情况下:不是) >当注册到达那一点时,我翻转变量并在iOS 7和-registerUserNotificationSettings上调用-registerForRemoteNotifi 我开发了一个应用程序,它围绕推送通知构建.仅当用户到达注册过程的某个点时,应用才会请求通知权限.我已经设法做了以下事情:

>该应用程序维护一个NSUserDefaults变量,该变量指示是否需要在启动时注册推送(默认情况下:不是)
>当注册到达那一点时,我翻转变量并在iOS 7和-registerUserNotificationSettings上调用-registerForRemoteNotificationTypes:在iOS 8上

除非用户已启用推送通知,然后稍后在“设置”中禁用推送通知,否则此工作正常.在这种情况下,我尝试在启动时重新注册Push,它不会调用-application:dIDRegisterForRemoteNotificationsWithDevicetoken或-application:dIDFailToRegisterForRemoteNotificationsWithError.

附加信息,iOS 8的-isRegisteredForRemoteNotifications也返回YES. (我没有测试,但假设-enablednotificationTypes适用于iOS 7.)

如何检测此方案并向用户显示请求者,要求他在“设置”中重新启用通知?

解决方法
[[UIApplication sharedApplication] isRegisteredForRemoteNotifications];

Returns a Boolean indicating whether the app is currently registered
for remote notifications.

Declaration SWIFT func isRegisteredForRemoteNotifications() -> Bool
OBJECTIVE-C
– (BOol)isRegisteredForRemoteNotifications Return Value YES if the app is registered for remote notifications and received its device token
or NO if registration has not occurred,has Failed,or has been denIEd
by the user.

discussion This method reflects only the successful completion of the
remote registration process that begins when you call the
registerForRemoteNotifications method. This method does not reflect
whether push notifications are actually available due to connectivity
issues. The value returned by this method takes into account the
user’s preferences for receiving push notifications.

Availability Available in iOS 8.0 and later.

Link to Apple Doc’s

我会向Apple提交一份错误报告.

总结

以上是内存溢出为你收集整理的ios – 延迟推送通知并检查用户是否启用了它全部内容,希望文章能够帮你解决ios – 延迟推送通知并检查用户是否启用了它所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1104256.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存