Uidevice Uniqueidentifier Deprecated - What to Do Now

UIDevice uniqueIdentifier deprecated - What to do now?

A UUID created by CFUUIDCreate is unique if a user uninstalls and re-installs the app: you will get a new one each time.

But you might want it to be not unique, i. e. it should stay the same when the user uninstalls and re-installs the app. This requires a bit of effort, since the most reliable per-device-identifier seems to be the MAC address. You could query the MAC and use that as UUID.

Edit: One needs to always query the MAC of the same interface, of course. I guess the best bet is with en0. The MAC is always present, even if the interface has no IP/is down.

Edit 2: As was pointed out by others, the preferred solution since iOS 6 is -[UIDevice identifierForVendor]. In most cases, you should be able use it as a drop-in replacement to the old -[UIDevice uniqueIdentifier] (but a UUID that is created when the app starts for the first time is what Apple seems to want you to use).

Edit 3: So this major point doesn't get lost in the comment noise: do not use the MAC as UUID, create a hash using the MAC. That hash will always create the same result every time, even across reinstalls and apps (if the hashing is done in the same way). Anyways, nowadays (2013) this isn't necessary any more except if you need a "stable" device identifier on iOS < 6.0.

Edit 4: In iOS 7, Apple now always returns a fixed value when querying the MAC to specifically thwart the MAC as base for an ID scheme. So you now really should use -[UIDevice identifierForVendor] or create a per-install UUID.

UIDevice uniqueIdentifier deprecated - What to do now?

A UUID created by CFUUIDCreate is unique if a user uninstalls and re-installs the app: you will get a new one each time.

But you might want it to be not unique, i. e. it should stay the same when the user uninstalls and re-installs the app. This requires a bit of effort, since the most reliable per-device-identifier seems to be the MAC address. You could query the MAC and use that as UUID.

Edit: One needs to always query the MAC of the same interface, of course. I guess the best bet is with en0. The MAC is always present, even if the interface has no IP/is down.

Edit 2: As was pointed out by others, the preferred solution since iOS 6 is -[UIDevice identifierForVendor]. In most cases, you should be able use it as a drop-in replacement to the old -[UIDevice uniqueIdentifier] (but a UUID that is created when the app starts for the first time is what Apple seems to want you to use).

Edit 3: So this major point doesn't get lost in the comment noise: do not use the MAC as UUID, create a hash using the MAC. That hash will always create the same result every time, even across reinstalls and apps (if the hashing is done in the same way). Anyways, nowadays (2013) this isn't necessary any more except if you need a "stable" device identifier on iOS < 6.0.

Edit 4: In iOS 7, Apple now always returns a fixed value when querying the MAC to specifically thwart the MAC as base for an ID scheme. So you now really should use -[UIDevice identifierForVendor] or create a per-install UUID.

Method [[UIDevice currentDevice] uniqueIdentifier] is not allowed any more, I need an alternative

The documentation recommends what to do in this section.

Special Considerations

Do not use the uniqueIdentifier property. To create a unique identifier specific to your app, you can
call the CFUUIDCreate function to create a UUID, and write it to the
defaults database using the NSUserDefaults class.

To make sure that the unique identifier remains after you delete the app you should store it in the keychain rather than NSUserDefaults. Using the keychain you will also be able to share the same unique ID across all of your apps on the same device using keychain access groups. This approach will prevent you from incorrectly tracking users after the device is no longer theirs, and it will be available on any new iDevice they restore from backup.

the warning 'uniqueIdentifier' is deprecated in project based on cocos2d-box2d

You can use for example OpenUDID https://github.com/ylechelle/OpenUDID

As LearnCocos2D told in a comment there is also a topic on SOF : UIDevice uniqueIdentifier Deprecated - What To Do Now?

Deprecated Xcode issues

UIDevice uniqueIdentifier property is deprecated in iOS 5 and above

    udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSLog(@"UDID : %@", udid);

How to fetch unique id for iPhone device

You can save str_udid object into the Keychain. Here is the link about how to do that: https://github.com/kishikawakatsumi/KeychainAccess

It will not remove even if you have deleted your application from the device.

iOS7 - Device unique identifier

3) Any other suggestions...

You should consider strategies for identifying and authorizing the user instead of the device. Depending on a device-specific identifier prevents authorized users from switching devices without some sort of administrator interaction, and allows non-authorized users access if they happen to find/steal/borrow an authorized device. You can avoid these problems by relying on user credentials instead of device identifiers.



Related Topics



Leave a reply



Submit