使用 APN 的应用程序似乎习惯于在应用程序启动时从操作系统获取 token 。但是,如果一个应用程序已经获取过一次,那么它是否需要再次获取它(如果已经这样做,则将其发送到服务器)是否有任何意义。
从操作系统获取的 APN token 是否会发生变化?
最佳答案
您问题的答案在 Apple 文档(本地和推送通知编程指南)中:
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.
关于ios - APN token 能否/将会改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10842349/