Always get a unique device id in iOS 7 Always get a unique device id in iOS 7 ios ios

Always get a unique device id in iOS 7

Use this little helper method to keep identifier in Keychain between install/delete sessions of app

-(NSString *)getUniqueDeviceIdentifierAsString{    NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];    NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:@"incoding"];    if (strApplicationUUID == nil)    {        strApplicationUUID  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];        [SSKeychain setPassword:strApplicationUUID forService:appName account:@"incoding"];    }    return strApplicationUUID;}

Add the SSKeychain library to your project, e.g. via Cocoapods with pod 'SSKeychain'

What is UDID replaced with?

For now it looks like Apple plan to replace UDID’s with two different identifiers: Vendor IDs and Advertising IDs.

Vendor IDs

ID that is identical between apps from the same developer.Erased with removal of the last app for that Team ID.

Advertising IDs

Unique to the device.Available to all applications; used for advertising — iAd has converted from UDID for iOS 6 and later.Reset with “Erase All Content & Settings”.

For the most part, Vendor IDs will allow developers with multiple apps to identify you as the same user across all their apps. This can help developers understand their audience better and provide a better service.

Advertising IDs will still create a unique identifier for the device but unlike the UDID, this can be turned off or reset, just as cookies can be controlled in the browser on your desktop or laptop.

With the announcement of iOS7 earlier this week, Apple took an additional step, which was to turn off another unique identifier — the “MAC Address” that app developers and advertising companies could use instead of the new Advertising ID. By closing this loophole, Apple is taking the good step of forcing these companies to only use a cross-app identifier that users can control.

What remains to be seen is whether the targeting companies will continue to seek ways around Apple’s mandate. Other technologies, like “device fingerprinting,” have been developed to uniquely identify your device outside of Apple’s framework. Whether Apple will crack down on these methods remains to be seen.

From the UIDevice Class reference for identifierForVendor:

The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. The value can also when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.