Is there any way to get the iOS device identifier in iOS SDK? I would like to access the identifier which is presented by the Xcode in Organizer - Devices section, something like: 21xb1fxef5x2052xec31x3xd3x48ex5e437xe593
-
Why do you want to get that identifier? – Nick Bull Dec 20 '12 at 12:41
-
2I need to uniquely identify the device – aumanets Dec 20 '12 at 12:49
6 Answers
It looks like you still can access UDID under iOS 6, but it is deprecated since iOS 5.0 and you shouldn't use it (anyway you'll get warning about that)
[UIDevice currentDevice].uniqueIdentifier
If you need unique identifier you should rather use :
[UIDevice currentDevice].identifierForVendor
or if it is connected with some kind of advertisement then:
// from AdSupport.framework
[ASIdentifierManager sharedManager].advertisingIdentifier
However those two new properties are available only under iOS >= 6.0, also advertisingIdentifier is not really unique (I'm getting many duplicates from that).
I suppose that you can do something like that if you wan't to support also iOS < 6:
UIDevice *device = [UIDevice currentDevice];
NSString *ident = nil;
if ([device respondsToSelector:SEL(identifierForVendor)]) {
ident = [device.identifierForVendor UUIDString];
} else {
ident = device.uniqueIdentifier;
}
but I'm not sure how apple will respond to that during review.
You can also use some 3rd party solution like openUDID or secureUDID. Open and secure UDIDs are deprecated - use identifier for vendor/advertising.
Update
One more possibility is to use MAC address as a base for unique hash, for example you can use code from ODIN1 - source is here
As of iOS7 MAC address is no longer available. (one can read it but it'll be always same dummy address 02:00:00:00:00:00).

- 4,208
- 17
- 19
-
-
yeah, sorry, at first I wrote uniqueIdentifier instead of identifierForVendor, but anyway I think it was quite obvious that something is wrong when I wrote that you shouldn't use uniqueIdentifier and in second line that you should use it ;) – lupatus Dec 20 '12 at 13:40
-
SecureUDID is no longer supported by Crashlytics; they write: "We recommend using Apple's iOS 6 vendor and advertising identifiers instead.". – Andreas Ley Jun 24 '13 at 08:12
-
thanks, I updated my answer also with MAC address which is not available since iOS7 – lupatus Jun 24 '13 at 08:49
From the Apple Documentation:
An alphanumeric string unique to each device based on various hardware details. (read-only) (Deprecated in iOS 5.0. Use the identifierForVendor property of this class or the advertisingIdentifier property of the ASIdentifierManager class instead, as appropriate, or use the UUID method of the NSUUID class to create a UUID and write it to the user defaults database.)
NSString* identifier = nil;
if( [UIDevice instancesRespondToSelector:@selector(identifierForVendor)] ) {
// iOS 6+
identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
// before iOS 6, so just generate an identifier and store it
identifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"identiferForVendor"];
if( !identifier ) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
identifier = (__bridge_transfer NSString*)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
[[NSUserDefaults standardUserDefaults] setObject:identifier forKey:@"identifierForVendor"];
}
}

- 7,428
- 1
- 47
- 45
you can find unique device identifier as
[[UIDevice currentDevice] uniqueIdentifier]

- 676
- 4
- 10
+ (NSString *)uuid
{
NSString *uuidString = nil;
CFUUIDRef uuid = CFUUIDCreate(NULL);
if (uuid) {
uuidString = (NSString *)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
}
return [uuidString autorelease];
}
It works 100%, even on simulators too...

- 26,890
- 5
- 80
- 110

- 264
- 4
- 9
Yes there is.
[[UIDevice currentDevice] uniqueIdentifier]
EDIT: However this is deprecated in iOS 5. This identifier should no longer be used in iOS 5. Read this SO post for more details.
-
3This is deprecated in iOS 5 and applications using this will not be allowed into the App Store. – Tom van der Woerdt Dec 20 '12 at 12:46