如何在iPhone上生成良好的,不变的UDID

在iOS 5中,不推荐使用[[UIDevice currentDevice] uniqueIdentifier].我们现在鼓励使用自己生成的UUID并将它们存储在应用程序的NSDefaults中.我想这对于大多数用途来说都没问题.

但我的问题是 – 是否有可能以某种方式生成UUID,其行为与现在的设备ID相似 – 即使在删除并重新安装应用程序后,我仍希望保持相同.这样做的目的是帮助跟踪从iPhone获取的可能的欺诈尝试.

我想知道是否使用MAC地址,就像这个类别:https://github.com/erica/uidevice-extension/blob/master/UIDevice-Hardware.m会好吗?

最佳答案 有关文档中uniqueIdentifier属性的讨论说明:

Do not use the uniqueIdentifier property. To create a unique
identifier specific to your app, you can call the CFUUIDCreate
function to create a UUID, and write it to the defaults database using
the NSUserDefaults class.

将其写入用户默认值应确保在删除/重新安装应用程序时保留它我会想到.

编辑:

对不起,they are not kept when an application is removed显然. documentation描述了如何生成UUID,但我无法确定它对于给定的用户/设备是否是常量.我见过一些人建议使用keychain通过app删除/重新安装来保持持久性,但不知道它是多么值得推荐(在任何情况下,用户都可以删除条目).

点赞