iphone - didRegisterForRemoteNotificationsWithDeviceToken - 推送通知

标签 iphone objective-c ios push-notification apple-push-notifications

我只是想确认“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/

相关文章:

iphone - 如何运行 iPhone 模拟器 (Aspen) 的两个实例来尝试 WiTap 示例?

iphone - 我如何泄漏内存?

objective-c - NSArray组件JoinedByString内存泄漏

iphone - 如何在 Mapkit MapView 上显示指南针/航向

objective-c - 为整个项目更改 UILabel 的文本颜色

ios - 如何从 youtube 下载视频并保存( objective-c )?

objective-c - nib 中顶级对象的加载顺序

ios - periodicalTimeObserver 在 AVPlayer 中使用 Swift 进行持续时间倒计时

ios - Swift 过滤字符串数组

iphone - IOS 中是否存在用于 UI 控件自动化的现有库