didRegisterForRemoteNotificationsWithDeviceToken - 推送通知 [英] didRegisterForRemoteNotificationsWithDeviceToken - Push Notifications

查看:25
本文介绍了didRegisterForRemoteNotificationsWithDeviceToken - 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想确认didRegisterForRemoteNotificationsWithDeviceToken"是在每次应用程序加载时调用,我的 PHP 服务器或应用程序需要处理是否重新提交以存储在我的数据库中?或者有什么我想念的吗?

I just wanted to confirm "didRegisterForRemoteNotificationsWithDeviceToken" is meant to be called everytime the application loads and my PHP server or application needs to deal with whether or not to resubmit to store in my database? Or is there something I am missing?

谢谢詹姆斯

推荐答案

首先,您不打算直接调用此方法.相反,您应该在每次启动应用时调用 registerForRemoteNotificationTypes:,然后依次调用您必须实现的 application:didRegisterForRemoteNotificationsWithDeviceToken:.

First, you are not meant to call this method directly. Rather, you should call registerForRemoteNotificationTypes: on every launch of your app which then in turn calls application:didRegisterForRemoteNotificationsWithDeviceToken: which you must implement.

第二,是的,您应该每次都将令牌重新提交到您的服务器.来自文档:

Second, yes, you are supposed to resubmit the token to your server every time. From the documentation:

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

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.

这篇关于didRegisterForRemoteNotificationsWithDeviceToken - 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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