Skip to content

Instantly share code, notes, and snippets.

@Duraiamuthan
Last active August 29, 2015 13:58
Show Gist options
  • Save Duraiamuthan/9989640 to your computer and use it in GitHub Desktop.
Save Duraiamuthan/9989640 to your computer and use it in GitHub Desktop.
UDID alternative in iOS 6+
Is UDID deprecated?
Yes. UDID is deprecated in iOS 5.
What are the alternatives?
identifierForVendor and advertisingIdentifier.
What is identifierForVendor?
identifierForVendor is an same UUID for all the apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.
What is a vendor?
A vendor is defined by the first two parts of the reverse DNS formatted CFBundleIdentifier. For example, com.2359media.app1 and com.2359media.app2 would have the same identifierForVendor. But my.hungrygowhere.iphoneapp and com.2359media.hgwm would get a different identifierForVendor.
How do I get identifierForVendor?
NSString *vendorID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
Is identifierForVendor persisted?
NO. identifierForVendor remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them.
What is advertisingIdentifier?
AdvertisingIdentifier is an UUID for each device, used only for serving advertisement. Unlike the identifierForVendor, the same value is returned to all vendors.
How do I get advertisingIdentifier?
Add AdSupport.framework
Import the following class <AdSupport/ASIdentifierManager.h>
Use the following code snippet
NSString *adID = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
Is advertisingIdentifier persisted?
No. advertisingIdentifier remains the same value until:
The user does a full system reset (Settings.app -> General -> Reset -> Reset All Content and Settings)
The User explicitly resets it (Settings.app -> Privacy -> Advertising -> Reset Advertising Identifier)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment