Alternative way to create lifetime unique id

Sunil Zalavadiya picture Sunil Zalavadiya · Apr 13, 2013 · Viewed 7.6k times · Source

I want to create UDID for iphone/ipad device which will remain unchanged, so please tell me if any one have idea for that?

I have search around google and stack-overflow, but not got solution.

Also some suggested to use OpenUDID and CFUUID, but CFUUID will be different when users delete and reinstall your app. But i want to use same UDID per application which will generated at first time and should remain unchanged for lifetime per device for each application.

Answer

βhargavḯ picture βhargavḯ · Apr 13, 2013

EDIT 2

Because of iOS upgrade and as per new documentation identifierForVendor does not retain value on app re-installs. I have seen answer at this link. This may help in one or other way. Just to note only UDID will retain even if system reset, So probably this answer can become limitation for developers seeking for lifetime UDID even on system reset. Other than this, mentioned answer seems useful.

Also look the summary here.


identifierForVendor is available from UIDevice Class Reference.

The value of this property is the same for apps that come from the same vendor running on the same device.

[[UIDevice currentDevice] identifierForVendor].UUIDString

Note: Available in iOS 6.0 and later.

EDIT 1 As per new release of UIDevice Class Reference

The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.


EDIT

I would like you to see at this popular link

1) MD5 of MAC+CFBundleIdentifier

[[UIDevice currentDevice] uniqueDeviceIdentifier]

This will remain same per app but different for each app. If you delete and reinstall your app it will be same per app.

2) MD5 of the MAC

[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]

This will remain same for all app from same device. If you delete and reinstall your app it will be same per device.

EDIT 3

Note: This solution in iOS 7 is no longer useful as uniqueIdentifier is no longer available from iOS7.