即使 iPhone 未连接到互联网,也收到设备令牌 [英] Device Token Received even after iPhone is not connected to Internet

查看:20
本文介绍了即使 iPhone 未连接到互联网,也收到设备令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试我的 iOS 应用时发现一件有趣的事情,即使我的手机处于飞行模式并且我也关闭了 WIFI,我的应用能够在注册推送通知后接收设备令牌.

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.

即使在从 iPhone 中删除应用程序及其相关证书后,我也尝试过.

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

但得到了相同的结果.

怎么可能,知道吗?

提前致谢.

推荐答案

本文来自 APNS 编程指南:

This is from the APNS programming guide :

通过每次请求设备令牌并将其传递给提供者当你的应用程序启动时,你帮助确保提供者具有设备的当前令牌.如果用户将备份恢复到除为其创建备份的设备或计算机之外的设备或计算机(例如,用户将数据迁移到新设备或计算机),他或者她必须至少启动应用程序一次才能接收再次通知.如果用户将备份数据恢复到新设备或计算机,或重新安装操作系统,设备令牌变化.此外,永远不要缓存设备令牌并将其提供给您的提供者;随时从系统获取令牌.如果你的应用之前已经注册过,调用registerForRemoteNotificationTypes:导致操作系统立即将设备令牌传递给委托,而不会产生额外的开销.

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.

这意味着如果您的应用程序已经注册了推送通知,则调用 registerForRemoteNotificationTypes 不会访问 APNS 服务器.

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

您卸载该应用程序的事实不会将其从 APNS 注销.您可以在卸载应用程序后立即调用反馈服务来证明这一点.在这种情况下,您不会从反馈服务获得设备令牌,因为 APN 服务不知道您卸载了应用程序.只有在卸载应用程序后向设备发送通知,APN 服务才会知道应用程序已被卸载.

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.

这篇关于即使 iPhone 未连接到互联网,也收到设备令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆