唯一标识 iOS 设备的最佳方式?

Best way to uniquely identify iOS device?

我知道如果以下方法各有缺陷

UDID 的问题是它已被弃用并且从 ios7 开始甚至无法工作,其他两个的问题是用户可以通过 phone 的软件重置或重新安装应用

我发现的另一个有趣的解决方案是自己随机生成一个,然后保存到钥匙串以避免在重新安装应用程序时删除,但是这是否适用于软件重置?两台设备随机生成相同 ID 的可能性很小吗?

我认为最好的选择可能是使用 UDID,但我想知道,即使 UDID 在 ios7 时不正确,它是否仍然是唯一的?

另一个选项是 MAC 地址,但据我所知,这些

没有 API

请指教最佳方案

开始 iOS 7 推导 MAC 地址是不可能的。但是,您可以使用以下内容:

[[[UIDevice currentDevice] identifierForVendor] UUIDString]

根据 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.