My app uses UIDevice currentDevice identifierForVendor
to help me identify the device. Recently I have encountered a situation that I can't understand. A UIDevice currentDevice identifierForVendor
of an iPad of one of my clients seems to have changed. Is this ever possible?

- 5,722
- 18
- 72
- 120
-
What do you mean by "identify" the device. How has it changed? Do you mean identifierVendor? – Larme Jul 10 '15 at 15:14
-
Use this to detect if your user is on a iphone or ipad http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices/26017764#26017764 – Sam B Jul 10 '15 at 15:19
-
Well I understood that UIDevice currentDevice gave you a unique, fixed identifier for a device that never changes. I use it to identify the iPad that was used to complete some work which is then sent to a central database. – RGriffiths Jul 10 '15 at 15:20
5 Answers
UIDevice Class Reference say :
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.
You can use KeyChain to store something unique as UUID(Create by your own method or use API). This may be helpful for you.

- 1
- 1

- 1,630
- 15
- 25
UIDevice currentDevice
simply returns information about the currently running device. Within that there are several properties you can check. I assume you are checking [UIDevice currentDevice] identifierForVendor]
If that is the case, YES it can change. If the user deletes your app AND all other apps created by you (the app vendor) then the identifierForVendor
can change. Another case where it can change is if it was not installed from the App Store and then later is. For example, you give your client an ad-hoc build to test and then later they install the real app from the App Store.

- 3,503
- 1
- 17
- 26
-
That is a very clear answer. Thank you. As a supplementary then, is there a unique device ID that does not change? – RGriffiths Jul 10 '15 at 15:32
-
1It is best to assign your client a unique ID from your end and store it within the keychain. For example you can use a UUID. – rmp Jul 10 '15 at 15:34
Another solution I found while searching for an unique and fixed ID for an "almost" consistently/fixed ID is to use the advertisingIdentifier. You can check the ASIdentifierManager. To have access to the ID you need just this:
@import AdSupport
...
NSString *id = [[ASIdentifierManager sharedManager] advertisingIdentifier];
This ID will be reset if the device has his settings reseted or his advertising identifier reseted.
Currently I'm sticking with the creation of a new UUID using
NSString *UUID = [[NSUUID UUID] UUIDString];
and storing it somewhere.

- 459
- 4
- 19
-
UPDATE: In latest iOS, user can disable/decline. So you must have a plan to handle a response containing all zeroes. You also have to inform Apple when submit app whether you use advertising identifier. And ask user's permission. Bottom line: just stop using this - its a privacy anti-pattern and users correctly resist it; generate your own GUID for the user, and store it both on your server, and in device's secure storage. – ToolmakerSteve Jul 19 '21 at 14:17
There appears to be a bug that surfaced around the end of May that causes identifierForVendor
to return a new identifier after a user updates the app in the App Store, when according to the documentation it should return the same identifier. See these and these Apple developer forum posts. I've seen this too and it affects about 20% of my users.

- 36
- 1
- 1
[UIDevice currentDevice] is not an identifier. It's an instance of a class. I assume you mean identifierForVendor, which is unique but not fixed.
The documentation is fairly helpful to understanding it, as well as providing alternatives. One that isn't listed is the device token for push notifications, but that's a whole different bag which you many not want to get into.

- 520
- 5
- 13
-
2Yes - updated question. Ticked answer explains it perfectly. Thanks – RGriffiths Jul 10 '15 at 15:38
-