为什么我的 app,在断网情况下,也能收到苹果返回的 deviceToken?

新手上路,请多包涵

我把测试机上的app删除了

然后在appdelegate中的didRegisterForRemoteNotificationsWithDeviceToken方法打上断点

然后把测试机断wifi并飞行,然后运行

我的 app 还是能收到 deviceToken。

这是为什么呢,deviceToken 的获取不是必须在联网状态下么?

阅读 2.5k
2 个回答

*在第一次调用registerForRemoteNotificationTypes方法时没有联网,则既不会调用didRegisterForRemoteNotificationsWithDeviceToken,也不会调用didFailToRegisterForRemoteNotificationsWithError

*在第一次调用registerForRemoteNotificationTypes注册成功后,之后即使没有联网,再调用registerForRemoteNotificationTypes时都会以最上一次的device token作为参数回调didRegisterForRemoteNotificationsWithDeviceToken方法。

  • (官方描述) If your application has previously registered, calling registerForRemoteNotificationTypes: results in the operating system passing the device token to the delegate immediately without incurring additional overhead.

非原创

新手上路,请多包涵

应该是缓存的,请求不是每次都

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题