[英]Why is my unique device ID changing when I delete the app from the same iPhone in Swift?
I am getting the current device ID of an iPhone by using the below code:我正在使用以下代码获取 iPhone 的当前设备 ID:
let deviceId: String = (UIDevice.current.identifierForVendor?.uuidString)!
...but when I delete the app from the same phone its ID is changing. ...但是当我从同一部手机中删除应用程序时,它的 ID 正在改变。 Why?
为什么?
The device ID has to be changed when I install the app in other devices.当我在其他设备上安装应用程序时,必须更改设备 ID。
How do I do that?我怎么做? Please help me with code.
请帮我写代码。
That's the way Apple designed it to work.这就是苹果设计它的工作方式。 From the documentation :
从文档中:
The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device.
当应用程序(或来自同一供应商的另一个应用程序)安装在 iOS 设备上时,此属性中的值保持不变。 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 change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution.
使用 Xcode 安装测试版本或使用 ad-hoc 分发在设备上安装应用程序时,该值也可能发生变化。 Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.
因此,如果您的应用程序将此属性的值存储在任何地方,您应该优雅地处理标识符更改的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.