且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS7和iOS8上:当用户说不推送通知的要求如何检测

更新时间:2023-02-03 09:43:13

didFailToRegisterForRemoteNotificationsWithError 方法不叫,因为注册没有失败 - 这是从来没有试图因为用户拒绝了这一要求。

Your didFailToRegisterForRemoteNotificationsWithError method isn't called, because the registration didn't fail - it was never even attempted because the user denied the request.

在iOS7你可以做两件事情:

On iOS7 you can do a couple of things:


  1. 假设远程通知才会可用 didRegisterForRemoteNotificationsWithDeviceToken 被称为

  2. 检查值 enabledRemoteNotificationTypes 的UIApplication 对象

  1. Assume that remote notifications aren't available until didRegisterForRemoteNotificationsWithDeviceToken is called
  2. Check the value enabledRemoteNotificationTypes on the UIApplication object