什么发生,如果一个APNS设备令牌过期? [英] What Happen If a APNS Device Token Expired?

查看:392
本文介绍了什么发生,如果一个APNS设备令牌过期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据该论坛的帖子<一个href=\"http://stackoverflow.com/questions/6652242/does-the-device-token-ever-change-once-created\">Does该设备令牌不断改变,曾经创造?的设备令牌可能会过期或APNS可能更改设备令牌。我的问题是,是否会APNS使用过期的令牌通知如果服务器发送此过期令牌苹果? APNS可以使用此令牌过期在另一台设备?

According to this forum post Does the device token ever change, once created? The device token might be expire or APNS might change the device token. My question is that whether the APNS will use the expired token for notification if the server send this expired token to Apple? Can APNS use this expired token for another device?

推荐答案

我从来没有遇到过一个过期的设备令牌,所以我无法从我的亲身经历告诉你。我也可以告诉你,从苹果的APNS文档,因为他们不回答你的问题(我读他们所有的APNS文档超过一次)。

I've never encountered an expired device token, so I can't tell you from my personal experience. Nor can I tell you from Apple's APNS documentation, because they don't answer your question (and I read all their APNS docs more than once).

您的应用程序和你的服务器应该能够处理设备令牌到期,无论到什么回答你的问题。

Your app and your server should be able to handle device token expiration regardless to what the answer to your question is.


  1. 总是调用 registerForRemoteNotificationTypes 当你的应用程序启动,并发送设备令牌服务器,如果它比过去的设备不同的令牌您的应用程序有该设备上

  1. Always call registerForRemoteNotificationTypes when your app is launched, and send the device token to the server if it's different than the last device token your app got on that device.

在您的服务器指定为使用你的应用程序的每个设备的另一个唯一标识符。安装了该应用发送标识符到您的服务器与设备一起令牌。这样一来,如果设备令牌的变化,你的服务器就会知道它是现有设备的新设备令牌,而不是在已安装您的应用程序的新设备。

Assign in your server another unique identifier for each device that uses your app. Have the app send that identifier to your server along with the device token. This way, if the device token changes, your server will know it's a new device token for an existing device and not a new device where your app was installed.

继#1和#2将确保您的服务器将在您的应用程序不是最近推出的每个在您的应用是最近推出的设备当前设备令牌(在设备上,用户可能穿上不在乎多关于你的应用程序,所以我不知道他们发送推送通知将使任何区别)。

Following #1 and #2 will ensure that your server will have the current device token for each device on which your app was launched recently (on devices where your app wasn't launched recently, the users probably don't care much about your app, so I'm not sure that sending them push notifications will make any difference).

如果你发送通知到旧设备的道理,如果它的工作原理,一切都很好。如果没有,你要么得到一个无效的令牌错误响应,或者你会得到的反馈服务,设备令牌。在这两种这些两种情况下,你应该停止将通知发送给该令牌。

If you do send a notification to an old device token, if it works, all is good. If it doesn't, you'd either get an Invalid Token error response or you'd get that device token in the Feedback service. In either of those two cases, you should stop sending notifications to that token.

我假设APNS不会重复使用其他设备过期的道理,但如果这样做,您的服务器可以通过使用唯一标识符我#2建议识别它。在这种情况下,要确保你的服务器只对其他设备的设备令牌分配。

I assume APNS won't reuse an expired token for another device, but if it does, your server can identify it by using the unique identifier I suggested in #2. In that case, make sure your server assigns the device token only to the other device.

这篇关于什么发生,如果一个APNS设备令牌过期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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