Every iPad and iPhone has a unique device identifier (UDID), a 40-character 40 character string that is hard-coded to each individual device.
It looks something like this:
a004e3409a473b2034d899d246...
UDID and UUID are different terms: a unique device identifier (UDID) identifies a device, while a universally unique identifier (UUID) is a general-purpose identifier.
The 40-character UDID format described above was used by devices of this era. Some newer Apple devices use a different format, introduced in 2018.
Since the early days of iPhone development, it’s been common practice for developers to use the UDID to associate devices with end users end-users and for analytics, security, etc.
In the latest major release of the iOS software development kit (SDK), version 5.0, Apple has deprecated the application programming interface (API) call an app uses to get the UDID from the system ([UIDevice currentDevice].uniqueIdentifier).
From Wikipedia:
Deprecation – “In the process of authoring computer software, its standards or documentation, or other technical standards, deprecation is a status applied to features, characteristics, or practices to indicate that they should be avoided, typically because they have been superseded.”
Unlike some other vendors, Apple tends to promptly remove deprecated APIs from their SDKs, so it’s a good idea to move your app off of them quickly lest it break in a future iOS update.
Apple’s transition away from app access to the UDID happened in stages. Starting May 1, 2013, the App Store no longer accepted new apps or updates that accessed it. In iOS 7, released later that year, existing apps calling the old API no longer received the UDID. Instead, they received a 40-character string consisting of
FFFFFFFFfollowed by the same vendor identifier available throughidentifierForVendor, with its dashes removed.The UDID itself did not disappear. For example, an organization’s mobile device management (MDM) service can still receive it for an enrolled device, subject to the enrollment method and management channel. That is separate from an ordinary app accessing the identifier.
See also:
Recently, Apple has started rejecting apps that access the UDID call:
- “Amid Privacy Concerns, Apple Has Started Rejecting Apps That Access UDIDs”
- “Apple cracks down on UDID use”
- “Developers ‘scrambling’ because Apple changed the UDID access it said it would in August”
Apple recommends replacing the use of the UDID with an app-specific unique identifier.
Here’s some code that creates and stores a universally unique identifier (UUID) for the app:
- (NSString *)appUniqueId
{
static NSString * const APP_UNIQUE_ID_USERDEFAULTS_KEY = @"AppUniqueIdUserdefaultsKey";
// Do we already have a unique id for this app?...
NSString *uniqueId = [[NSUserDefaults standardUserDefaults] objectForKey:APP_UNIQUE_ID_USERDEFAULTS_KEY];
// ... if not, create it...
if( uniqueId == nil )
{
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
uniqueId = (NSString *)CFUUIDCreateString(kCFAllocatorDefault,uuidRef);
CFRelease(uuidRef);
[[NSUserDefaults standardUserDefaults] setObject:uniqueId forKey:APP_UNIQUE_ID_USERDEFAULTS_KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
[uniqueId autorelease];
}
return uniqueId;
}
Apple publicly introduced Swift in June 2014, more than two years after this article was published.
Unlike the UDID, the app-specific unique identifier will reset if the app is ever deleted and reinstalled re-installed on the device, so if your you’re app relies on the same identifier for security, you’ll have to account for this case.
Enjoy!