我只是想确认“didRegisterForRemoteNotificationsWithDeviceToken”是指在每次应用程序加载时调用并且我的 PHP 服务器或应用程序需要处理是否重新提交以存储在我的数据库中?还是我缺少什么?
谢谢 詹姆斯
最佳答案
首先,您不应该直接调用此方法。相反,您应该在每次启动您的应用时调用 registerForRemoteNotificationTypes:
,然后依次调用您必须实现的 application:didRegisterForRemoteNotificationsWithDeviceToken:
。
其次,是的,您应该每次都将 token 重新提交到您的服务器。来自文档:
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 other than the one that the backup was created for (for example, the user migrates data to a new device), 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 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 iOS passing the device token to the delegate immediately without incurring additional overhead.
关于iphone - didRegisterForRemoteNotificationsWithDeviceToken - 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4804148/