Skip to content

Instantly share code, notes, and snippets.

@hujunfeng
Last active January 24, 2024 14:15
Show Gist options
  • Star 53 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save hujunfeng/6265995 to your computer and use it in GitHub Desktop.
Save hujunfeng/6265995 to your computer and use it in GitHub Desktop.
UDID, identifierForVendor and advertisingIdentifier FAQ

What's the difference between UUID, GUID and UDID?

  • UUID (Universally Unique Identifier): A sequence of 128 bits that can guarantee uniqueness across space and time, defined by RFC 4122.

  • GUID (Globally Unique Identifier): Microsoft's implementation of the UUID specification; often used interchangeably with UUID.

  • UDID _(Unique Device Identifier)): A sequence of 40 hexadecimal characters that uniquely identify an iOS device (the device's Social Security Number, if you will). This value can be retrieved through iTunes, or found using UIDevice -uniqueIdentifier. Derived from hardware details like MAC address.

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?

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)
@ryancarlson
Copy link

According to Apple's guide, the section about "What is a Vendor?" is slightly incorrect. It would be true for apps not installed from the App Store. However, apps installed from the App Store do not rely on the bundle identifier to determine which vendor they are from.

Normally, the vendor is determined by data provided by the App Store. If the app was not installed from the app store (such as enterprise apps and apps still in development), then a vendor identifier is calculated based on the app’s bundle ID. The bundle ID is assumed to be in reverse-DNS format.

Reference: https://developer.apple.com/reference/uikit/uidevice/1620059-identifierforvendor

@Augustyniak
Copy link

Augustyniak commented Aug 30, 2017

iOS 11 introduces new API that allows applications to track a device. You can learn more about it at https://developer.apple.com/documentation/devicecheck and https://developer.apple.com/videos/play/wwdc2017/702/ (24. minute).

@devforey
Copy link

data provided by the App Store

This is too vague, is this "data" from the Distribution certificates? Is this data persisted even if I revoke the app's Distribution certificates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment