Device Token Received even after iPhone is not connected to Internet

谁说胖子不能爱 提交于 2019-12-21 05:43:09

问题


I was testing my iOS app I found one interesting thing that even my phone is in airplane mode and I have also switched off WIFI, my app is able to receive the the Device Token after registering for push notification.

I have also tried even after removing app and its associated certificate from the iPhone.

but got same results.

How is it possible, any idea ?

thanks in advance.


回答1:


This is from the APNS programming guide :

By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device or computer other than the one that the backup was created for (for example, the user migrates data to a new device or computer), he or she must launch the application at least once for it to receive notifications again. If the user restores backup data to a new device or computer, or reinstalls the operating system, the device token changes. Moreover, never cache a device token and give that to your provider; always get the token from the system whenever you need it. 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.

It implies that if your application is already registered for push notifications, calling the registerForRemoteNotificationTypes doesn't access the APNS server.

The fact that you uninstalled the app doesn't unregister it from APNS. You can prove that to yourself by calling the feedback service immediately after uninstalling the app. You wouldn't get the device token from the feedback service in this case, because the APN service doesn't know you uninstalled the app. Only if you send notifications to the device after uninstalling the app, the APN service will know the app was uninstalled.



来源:https://stackoverflow.com/questions/15432793/device-token-received-even-after-iphone-is-not-connected-to-internet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!