Search code examples
iosmac-addressudididentify

Best way to uniquely identify iOS device?


I'm aware if the following methods, each which has it'd flaws

  • UDID
  • Advertising Identifier
  • Vendor ID

The problem with UDID is that its deprecated and doesn't even work as of ios7, problem with other two is that the user can change them via software reset of phone or reinstallation of app

Another interesting solution I found is to randomly generate one yourself and then save to keychain to avoid deletion upon app reinstallation however would this work across software resets? And surely there's a very small chance that two devices would randomly generate the same ID?

I think the best option might be to use UDID but I would like to know if, even though the UDID is incorrect as of ios7, is it still unique?

Yet another option is MAC address but as far as I know, there is no API for these

Please advise on the best option


Solution

  • Starting iOS 7 deducing MAC address isn't possible. You can, however, use below:

    [[[UIDevice currentDevice] identifierForVendor] UUIDString]
    

    Per Apple Documentation:

    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.