Swift
Swift

Reputation: 1184

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:

 let deviceId: String = (UIDevice.current.identifierForVendor?.uuidString)!

...but when I delete the app from the same phone its ID is changing. Why?

The device ID has to be changed when I install the app in other devices.

How do I do that? Please help me with code.

Upvotes: 2

Views: 7146

Answers (1)

Jim
Jim

Reputation: 73936

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. 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. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.

Upvotes: 4

Related Questions