ios 设备令牌是否与设备 ID 一样唯一?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6927011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:56:39  来源:igfitidea点击:

Is the device token as unique as the device ID?

iphoneiosdevicetoken

提问by Nielsou Hacken-Bergen

If we reset an iPhone, the device ID remains the same. Is it the same for the device token?

如果我们重置 iPhone,设备 ID 将保持不变。设备令牌是否相同?

回答by Mic Pringle

I assume you are referring to the device token available to methods such as

我假设您指的是可用于方法的设备令牌,例如

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

If this is the case, then no, the device token canand will change.

如果是这种情况,那么不,设备令牌可以并且将会改变

Quoted from Apples Local and Push Notification Programming Guide

引自 Apples Local and Push Notification Programming Guide

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

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

I can also verify this behaviour as I use Urban Airshipas my notification provider and even though I have only ever used a single test device so far, there are numerous device tokens registered with my account.

我也可以验证这种行为,因为我使用Urban Airship作为我的通知提供程序,尽管到目前为止我只使用过一个测试设备,但我的帐户中注册了许多设备令牌。

回答by annu

Device token is unique id but will be change.

设备令牌是唯一的 ID,但会发生变化。