描述:
我把测试机上的app删除了
然后在appdelegate中的didRegisterForRemoteNotificationsWithDeviceToken方法打上断点
然后把测试机断wifi并飞行,然后运行
我的 app 还是能收到 deviceToken。
这是为什么呢,deviceToken 的获取不是必须在联网状态下么?
解决方案1:
应该是缓存的,请求不是每次都
解决方案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.
非原创