Reputation: 629
I have created a function to get UUID
func deviceUUID() -> String {
return UIDevice.currentDevice().identifierForVendor?.UUIDString ?? ""
}
But the problem is that when ever I uninstall the app from same device and re-install it. I am getting a totally new UUIDString. If this the default behaviour then can I get previous UUID somehow ? because I have UUID as user ID in our server.
I do have a solution in my mind but I do not know that will it work or not so please guide me on this.
Lets say I get the ID first time and save it in keychains. When user reinstall the app I get the ID from keychains. Is this possible ?
Upvotes: 2
Views: 2298
Reputation: 69459
This correct behavior as described in UIDevice documentation.
If you want to store some identifier that is persisted when the app is uninstalled you should save a unique value in the keychain.
Just be aware that even these will not be 100% stored, the user can delete then if he/she has knowledge of the keychain or the device is wiped.
Upvotes: 2