Dou*_*ith 3 cocoa-touch objective-c keychain apple-push-notifications ios
我想确保我的服务器始终具有最新的APNS设备令牌,该令牌可以在特定情况下更改.
我应该将它保存到钥匙串,并在启动时检查它是否不同,然后如果是这样更新服务器?
这是最好的方式吗?
Apple实际上说不要在本地存储设备令牌.您registerForRemoteNotifications()需要设备令牌时调用.来自Apple:
Never cache a device token; always get the token from the system whenever you need it. If your app previously registered for remote notifications, calling the registerForRemoteNotifications method again does not incur any additional overhead, and iOS returns the existing device token to your app delegate immediately. In addition, iOS calls your delegate method any time the device token changes, not just in response to your app registering or re-registering.
因此,您需要做的是在启动时注册远程通知,并将该令牌发送到您的服务器.来自Apple:
Device tokens can change, so your app needs to reregister every time it is launched and pass the received token back to your server.
您可以在此处找到更多文档:https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW25
| 归档时间: |
|
| 查看次数: |
1901 次 |
| 最近记录: |