UDID is a hash value composed from various hardware identifiers such as the device serial number.
It is unique for each device.
The UDID is independent of the device name, SIM card.
It is really easy to get it from the device programmatically:
NSString *uuid = [[UIDevice currentDevice] uniqueIdentifier];
But UDID is no longer available onwards iOS 6 due to security / privacy reasons.
UDID is deprecated by Apple; developers can not make use of it in any iOS application.
So what now? How can we identify the device?
I found many solutions on searching over internet like identifierForVendor or advertisingIdentifier or generate our own UUID (store & persist it on your own).
Many examples show how to generate UUID and store it in NSUserDefault:
Create & Store UUID in Keychain: Source Code
It is unique for each device.
The UDID is independent of the device name, SIM card.
It is really easy to get it from the device programmatically:
NSString *uuid = [[UIDevice currentDevice] uniqueIdentifier];
But UDID is no longer available onwards iOS 6 due to security / privacy reasons.
UDID is deprecated by Apple; developers can not make use of it in any iOS application.
So what now? How can we identify the device?
I found many solutions on searching over internet like identifierForVendor or advertisingIdentifier or generate our own UUID (store & persist it on your own).
Many examples show how to generate UUID and store it in NSUserDefault:
-(NSString *)generateUUID {
NSString *CFUUID = nil;
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"UUID"] == nil) {
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
CFUUID = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, uuid));
[[NSUserDefaults standardUserDefaults] setValue:CFUUID forKey:@"UUID"];
[[NSUserDefaults standardUserDefaults] synchronize];
} else {
CFUUID = [[NSUserDefaults standardUserDefaults] valueForKey:@"UUID"];
}
But if you store the UUID in NSUserDefaults you would loose it as soon as the app gets uninstalled from the device.
So the better idea is to store it in Keychain. In case the app is uninstalled Keychain will preserve the UUID and on next installation we can fetch it from there.