简体   繁体   中英

Device specific unique identifier

I am working on an app in which I need a device specific globally unique identifier (ie imei etc). I have tried the following code, but it always generates a new 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.

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 is also of the opinion that is this a breach of privacy.

A goto solution is using OpenUDID they will generate a unique key per application which is stored in keychain. 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 . At launch, check NSUserDefaults to retrieve the key. It won't "survive" a delete/re-install of the app though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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