写了一个 iOS 下生成和管理设备唯一标识符( UDID)的组件,分享一下...

2016-06-03 17:02:14 +08:00
 mushank
使用简单,就一行代码;轻量级,就一个类文件。
主要原理是采用 Keychain 来保存 IDFV ,能够保证在 App 被卸载、重装、 iOS 系统升级等一系列情况下设备的 UDID 不会发生改变。会保持持续更新,欢迎提issue...
附上地址: https://github.com/mushank/ZKUDIDManager

第一次发帖,好鸡冻...
5367 次点击
所在节点    iDev
29 条回复
mushank
2016-06-05 23:25:52 +08:00
@iyeatse 恩看到啦,非常感谢!
Dashit
2016-06-07 17:46:55 +08:00
不开 keychain 同步怎么办?
mushank
2016-06-07 22:25:18 +08:00
@Dashit 即使不开 iCloud 同步, App 被卸载 /重装 /iOS 系统升级之后、 UDID 也依旧在的。
Dashit
2016-06-08 08:41:34 +08:00
@mushank 你这个不是用的 IDFV 吗? UDID 只能通过特殊方法获取吧。
mushank
2016-06-08 10:11:59 +08:00
@Dashit 恩,这个是用 IDFV 实现 UDID 的功能。。。
vincentxue
2016-06-08 21:31:58 +08:00
楼主为什么要重复造轮子… https://github.com/fabiocaccamo/FCUUID
mushank
2016-06-09 17:22:21 +08:00
@vincentxue 自我觉得自己这个更简简洁易用。。。
daniellu
2016-06-17 18:12:30 +08:00
@mushank 刚刚查过了, identifierForVendor 对于同一个厂商来说,是不变的。如果是从 store 下载的, store 会给设定 vendor ,如果是用企业证书分发,是会用 bundle id 判断。这个个人觉得不会出现同一个供应商的程序卸载之后会不同,如果这样的话,也不需要提供这个 API 了。

唯一需要注意的是,用 bundle id 判断的时候, iOS 6 和 iOS 7+判断部分不同( iOS 6 是前 2 部分, 7+不是)。

The value of this property is the same for 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.

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.

On iOS 6, the first two components of the bundle ID are used to generate the vendor ID. if the bundle ID only has a single component, then the entire bundle ID is used.

On IOS 7, all components of the bundle except for the last component are used to generate the vendor ID. If the bundle ID only has a single component, then the entire bundle ID is used.
mushank
2016-06-27 19:40:35 +08:00
@daniellu "The value changes when the user deletes all of that vendor ’ s apps from the device and subsequently reinstalls one or more of them."
苹果官方文档,小伙子看文档要看完整。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/283285

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX