10

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.

jscs
  • 63,694
  • 13
  • 151
  • 195
Sunil Zalavadiya
  • 1,993
  • 25
  • 36
  • Think you could add an id for the application to a device ID and take the hash-code of that. I don't know how to get a fixed device ID on iThings though. – hack_on Apr 13 '13 at 04:45

3 Answers3

8

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.

Community
  • 1
  • 1
βhargavḯ
  • 9,786
  • 1
  • 37
  • 59
  • :- Value of identifierForVendor will not changed for that app for that device, right? – Sunil Zalavadiya Apr 13 '13 at 05:24
  • 1
    Value of identifierForVendor will never changed for that perticular Vender + App + Device. – Brijesh Vadukia Apr 13 '13 at 06:16
  • Apple document words: "The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor." – Brijesh Vadukia Apr 13 '13 at 06:17
  • 1
    @Bhargavi I have try same but ID remain same. – Pratik Apr 13 '13 at 06:21
  • @Bhargavi As per my testing it is remain same. Please let me know your result ? – Brijesh Vadukia Apr 13 '13 at 06:22
  • Pratik & Brijesh Thanks . You are right. I am getting same values too :) – βhargavḯ Apr 13 '13 at 06:35
  • @Bhargavi I have one question, If user update ios and/or install new ios then value of identifierForVendor will change or remain same? – Sunil Zalavadiya Apr 13 '13 at 07:06
  • 1
    @sunilz "if user update ios and/or install new ios then value of identifierForVendor will change or remain same?" - I am not sure but I think it should not get affected due to upgraded IOS version. – βhargavḯ Apr 13 '13 at 08:09
  • 1
    @Bhargavi Now apple has changed documents : "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." – Sunil Zalavadiya Sep 09 '13 at 04:14
  • @Bhargavi See following link:- https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/identifierForVendor – Sunil Zalavadiya Sep 09 '13 at 04:14
  • @sunilz Thanks for drawing my attention to new release. I have updated answer. – βhargavḯ Sep 09 '13 at 04:24
  • @Bhargavi You have another solution for it? – Sunil Zalavadiya Sep 09 '13 at 04:28
  • @sunilz Not now. But as soon as I get solution, I'll surely update on post. – βhargavḯ Sep 09 '13 at 04:31
  • @All I was also expecting that VedorId remains same for App+Vedor+Device. But, in current project It is changing on every install. Is anyone has faced this issue and has any solution then pls post. – Mrug Apr 18 '15 at 05:53
2

Its important to note the difference between a UDID and a UUID.

UDID "unique device id" is hardware specific. It never changes for a particular device. For this reason, it has become a privacy concern and Apple is blocking apps that try to use this. As a result, Apple has generated an opt-out-able "device id" hash, particularly for advertisement usage. This new ID hash is called IFA and is available in iOS 6.0+.

UUID "universally unique id" is not hardware specific. It is a hash used to identify a device; but not particularly an absolute value. For example, PhoneGap generates a UUID based on device properties; this is what you get when you do device.uuid. If you delete the app and reinstall, you will get a new id hash. UUID is not being blocked by Apple.

I think the best solution is to use the IFA, with OpenUDID as a backup for iOS < 6.0.

Here is the code we use. If IFA is not available, get OpenUDID. [[You must install OpenUDID, read more about that here, https://github.com/ylechelle/OpenUDID.]]

NSString* uuid = nil;
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
    // IOS 6 new Unique Identifier implementation, IFA
    uuid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
    // Before iOS6 (or if IFA disabled) you shoud use a custom implementation for uuid
    // Here I use OpenUDID (you have to import it into your project)
    // https://github.com/ylechelle/OpenUDID
    NSString* openUDID = [OpenUDID value];
    uuid = [OpenUDID value];
}
Federico
  • 6,388
  • 6
  • 35
  • 43
  • Thanks for your reply. But i have question, If you delete the app and reinstall, switch off device, update or install new ios then OpenUDID will remain same as previous? – Sunil Zalavadiya May 01 '13 at 04:07
  • You can read more about OpenUDID on the project site. But pretty much it is a universally unique string shared by multiple applications on the device. So for example, Gmail, Chrome, and Dropbox use OpenUDID (I have no idea, but just to use names for apps). The first application you download say Gmail will set the OpenUDID strong. The second and third application will read that same OpenUDID string. But say you then delete Gmail -- instead of the OpenUDID string being lost, it will be maintained by the other apps that use it. (To get rid of it, all apps must have been deleted). – Federico May 17 '13 at 20:34
0

Generate an UUID (using the CFUUIDRef API, perhaps) for the first time, and store it in the keychain.