1

I am working on an app in which I need a device specific globally unique identifier (i.e 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.

P.S:- I am using iOS 5 and iOS 6.

Ankur Arya
  • 4,693
  • 5
  • 29
  • 50
  • possible duplicate of [UIDevice uniqueIdentifier Deprecated - What To Do Now?](http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now) – Paulw11 Apr 21 '15 at 00:51

2 Answers2

3

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.

tkanzakic
  • 5,499
  • 16
  • 34
  • 41
rckoenes
  • 69,092
  • 8
  • 134
  • 166
0

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.

rdurand
  • 7,342
  • 3
  • 39
  • 72