ios-获取唯一标识符,重新安装应用程序后该标识符必须相同

标签 ios

我有一个用例,我想将用户与特定的设备 ID 绑定(bind)。为此,我需要一个唯一的设备标识符。

当我搜索这个问题时,我找到了一些解决方案,比如

  • 正在创建一个 UUID,但每次卸载时它都会更改 应用程序并重新安装。
  • 创建 UUID 将 ID 存储在用户默认值或 key 链中,但最新版本的 iOS 会在卸载应用程序时删除 key 链和用户默认值
  • 获取 mac id 也被弃用了,它们总是返回一个模拟值 MAC 地址 02:00:00:00:00:00

所以我的问题是可以读取任何唯一标识符吗? 如果是,那么我如何使用 swift 或 objective-c 阅读它?

最佳答案

至少 iOS 12.1 不会在应用程序卸载时删除钥匙串(keychain)。

这种删除行为曾在 iOS10.3 Beta 2 中引入,但后来恢复了。


在某些情况下,Apple 官方提供的 DeviceCheck API 可以作为解决方案。

如果它满足您的要求,这似乎是最可靠和体面的方式。

比较https://developer.apple.com/documentation/devicecheck

Using the DeviceCheck APIs, in combination with server-to-server APIs, you can set and query two bits of data per device, while maintaining user privacy. You might use this data to identify devices that have already taken advantage of a promotional offer that you provide, or to flag a device that you've determined to be fraudulent. The DeviceCheck APIs also let you verify that the token you receive comes from an authentic Apple device on which your app has been downloaded.

关于ios-获取唯一标识符,重新安装应用程序后该标识符必须相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54320833/

相关文章:

ios - 在不使用 aws 的情况下为 RestKit 生成 S3 bucket url

ios - 背景颜色在多个单元格选择 Swift 中自动更改

ios-charts 隐藏条形边界之外的值(堆积条形图)

ios - 在 iOS 上使用 API 获取 Google 联系人

ios - 为什么添加的子图层不显示在屏幕截图中?

ios - 添加的图像在表格 View 中显示不正确

ios - CGAffineTransform 和 NSLayoutConstraint 冲突

ios - 如何使用 Swift - 在 textView 中自动完成

ios - AVAssetExportSession exportAsynchronouslyWithCompletionHandler 有时不起作用

ios - 在 GetCell 方法中删除动态单元格