Skip to content
A substitute for the deprecated iOS method [[UIDevice currentDevice] uniqueIdentifier]. DEPRECATED, DO NOT USE FOR FUTURE PROJECTS.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


In iOS7, Apple removed support for querying the MAC address. All devices on iOS 7 will return the same MAC address, so you should migrate away from this code and simply use [[UIDevice currentDevice] identifierForVendor].

In the last commit for this project, I have added an upgrade path that can preserve the UDID generated by this API between iOS 6 and 7. If you push an update to your users with this code before they install iOS 7 (and call UDID at least once on iOS6), then their device identifier won't change after updating.

The upgrade path works like so: when the UDID method is called pre-iOS7, the Mac address and identifierForVendor are saved to disk (in NSUserDefaults). When it is called post-iOS7, if a cached MAC address exists (and the device is the same as when it was recorded, based on the saved identifierForVendor), the sha1 hashed MAC address is returned as before. Otherwise, a sha1 hash of identifierForVendor is returned. Thus, if you push an update with the latest UIDevice-UUID code to your users before iOS 7 and call UDID on iOS 6, their identifiers won't change post iOS 7 update.

Despite the above upgrade path, it's probably a good time to migrate to [[UIDevice currentDevice] identifierForVendor] if you can.


UIDevice-UDID is a replacement for the now deprecated [[UIDevice currentDevice] uniqueIdentifier] method. It is designed to be code compatible generating a string of the same number of characters, that should be unique per device. It isn't a drop-in replacement for fear of monkey patching over Apple's own methods. However you are free to rename the UDID method to uniqueIdentifier if you like (at your own risk).

No black magic, just a sha1 hash of the user's en0 MAC address. The SHA1 function is included in a separate .h/.m in case you'd like to use it independently. A method to get the user's MAC address (used to generate the UDID) is also exposed, in case you need it.

There are no release/retain/autorelease calls so it should work with or without ARC.

No rights reserved, this code is in the public domain. Do with it as you please.


#import "UIDevice+UDID.h"

// ... sometime later in your code

// for a true unique device identifier
NSLog(@"UDID: %@", [[UIDevice currentDevice] UDID]);

// for a unique device identifier just for your apps
NSLog(@"UDID with custom salt: %@", [[UIDevice currentDevice] UDIDWithSalt:@"some secret key"]);

// for a unique device identifier just for this specific app
NSLog(@"UDID with bundle-id salt: %@", [[UIDevice currentDevice] UDIDWithSalt:[[NSBundle mainBundle] bundleIdentifier]]);

// get the user's mac address (I probably wouldn't recommend using this as your UDID)
NSLog(@"MAC Address %@", [[UIDevice currentDevice]  macAddressForInterface:nil]);


The following sources provided useful code snippets for this little library:

Generating a SHA1 hash on iPhone

Getting the users Mac address

Something went wrong with that request. Please try again.