简体   繁体   English

为什么当我从 Swift 中的同一部 iPhone 中删除应用程序时,我的唯一设备 ID 会发生变化?

[英]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.

相关问题 当应用程序在我的设备(iPhone 6)上快速运行时,“没有可用的源1类型” - 'No available types for source 1' when the app runs on my device(IPhone 6) swift 为什么我的唯一设备 ID 发生了变化? - Why did my unique device ID change? 当iPhone / iPad上的设备方向发生变化时,如何处理Swift中的弹出式窗口 - How to handle popover in Swift when the device orientation is changing on iPhone/iPad iPhone应用程序(不是设备)的唯一标识符 - Unique identifier for an iPhone app, NOT device 从iPhone删除应用程序时Xcode崩溃 - Xcode crashes when I delete app from iPhone Swift Admob控制台显示模拟器设备ID,但在iPhone上运行时却没有? - Swift Admob console displays simulator device ID but not when running on iPhone? 当我从Swift的音乐库中选取一首歌曲时,为什么我的应用程序崩溃? - Why does my app crash when I pick a song from my music library in Swift? 在取消选中设备方向后,为什么iPhone窗台会旋转(从info.plist文件中删除旋转) - Why iPhone sill rotate after I uncheck the device orientation (delete rotation from info.plist file) 我可以在我的物理 iPhone 设备上通过 VSCode (Windows) 测试我的 Flutter 应用程序吗? - Can I test my Flutter App from VSCode (Windows) on my physical iPhone device? Swift 3数据没有从iPhone应用程序发送到蓝牙设备 - Swift 3 data not sending to bluetooth device from iPhone app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM