简体   繁体   English

设备特定的唯一标识符

[英]Device specific unique identifier

I am working on an app in which I need a device specific globally unique identifier (ie imei etc). 我正在开发一个应用程序,其中我需要一个特定于设备的全局唯一标识符(即imei等)。 I have tried the following code, but it always generates a new uuid . 我尝试了以下代码,但它始终生成一个新的uuid。

CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidStr = ( NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
CFRelease(uuid);

is there any way I can get a unique identifier that will last forever. 有什么方法可以得到一个永远持续的唯一标识符。

PS:- I am using iOS 5 and iOS 6. PS: - 我使用的是iOS 5和iOS 6。

Apple does not allow you to track unique device since the device can change hands and you really want to track the user not the device. Apple不允许您跟踪唯一设备,因为设备可以转手,而您确实想跟踪用户而不是设备。 Apple is also of the opinion that is this a breach of privacy. Apple也认为这是对隐私的侵犯。

A goto solution is using OpenUDID they will generate a unique key per application which is stored in keychain. goto解决方案使用OpenUDID,它们将为每个应用程序生成一个唯一密钥,该密钥存储在钥匙串中。 This means that if the user removes the app, the data in the keychain will persist. 这意味着如果用户删除了应用程序,则钥匙串中的数据将保持不变。

You can create yourself a unique key, and store it to NSUserDefaults . 您可以创建一个唯一的密钥,并将其存储到NSUserDefaults At launch, check NSUserDefaults to retrieve the key. 在启动时,检查NSUserDefaults以检索密钥。 It won't "survive" a delete/re-install of the app though. 它不会“幸存”删除/重新安装应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM