Swift:如何以编程方式获取 iOS 设备的唯一标识符? [英] Swift: how to programmatically get the unique identifier of an iOS device?
问题描述
我正在创建一个 iOS 应用,我需要一个唯一标识符,即使用户删除所有内容(重置为出厂设置),该标识符也必须相同.
I am creating an iOS app that I need a unique identifier that has to be the same even user removes all content(reset to factory settings).
我知道几年前我们可以获取 UDID,但现在我们只能创建一个 UUID,每次用户重新安装应用程序或将设备重置为出厂设置时,该 UUID 都会发生变化.
I know years ago we can get the UDID but right now we can only create an UUID which changes every time user re-install the app or reset device to factory settings.
推荐答案
这是故意不可能的.您不得以这种方式跟踪用户.如果您尝试解决此限制,Apple 可能会在未来的版本中破坏您的技术(他们已经悄悄地破坏了人们以前使用过的几个黑客,通常没有任何警告),并且他们可能会完全拒绝该应用.
This is intentionally impossible. You are not permitted to track the user this way. If you attempt to work around this restriction, Apple will likely break your technique in a future release (they've quietly broken several hacks people have used previously, generally without warning), and they may reject the app entirely.
识别设备的正确方法是使用 identifierForVendor代码>
.每当您从设备中删除最后一个应用程序并重新安装其中一个应用程序时,它就会重置为新值.(您的应用"是指与捆绑 ID 具有相同开头的应用.)可以重置它是一项系统功能,Apple 不允许您绕过它.
The correct way to identify a device is with identifierForVendor
. It is reset to a new value whenever the last of your apps is removed from the device and one of your apps is reinstalled. (By "your apps" I mean apps with the same start to their bundle id.) The fact that it can be reset is a system feature, and Apple does not allow you to circumvent it.
这篇关于Swift:如何以编程方式获取 iOS 设备的唯一标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!