>该应用程序维护一个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.
我会向Apple提交一份错误报告.