I have one product that has two different applications. and both the applications it gives me different Identifiers for the same device (you would assume that apple would associate this to maybe your developer account so that you can reuse the information across your applications), but I was wondering is their anything that would give me the same identifier for a device on both the applications?
identifierForVendor is really what you want. UDID is a big NO on the AppStore. A user can opt out to advertisingIdentifier. Other ways (by MAC address, like ODIN1, and solutions that rely on UIPasteboard, as OpenUDID) will break on the future (hint: 7).
According to the docs, you should have the same identifier if both apps are from the same developer:
The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.
The value of this property may be nil if the app is running in the background, before the user has unlocked the device the first time after the device has been restarted. If the value is nil, wait and get the value again later.
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. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.
OpenUDID is the best solution until now, even if it also may be changed if the device is reset.
Related
Every time I uninstall and install my app, a new identifierForVendor is generated.
I found out that it is an ongoing issue of Apple.
My follow-up question is, will it then be possible for two or more devices to have the same identifierForVendor if they keep uninstalling・reinstalling?
Teoretically yes, but for practical applications you shouldn’t need to worry about this.
identifierForVendor is of UUID type - this wiki page has a section on collision probability for UUIDs in general, not only on iOS. The short of it is that in order to have 50% chance of collision you’d need to generate ~2.71*10^18 identifiers. And thats
equivalent to generating 1 billion UUIDs per second for about 85 years. A file containing this many UUIDs, at 16 bytes per UUID, would be about 45 exabytes.
Also, I wouldn’t say that its an „issue”, but rather a decision choice made by Apple - in the documentation they clearly state that
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.
I want to make getting a new device as easy as possible in my iOS app.
However, I want to ensure that the old instance of the app (and more importantly the data) is no longer accessible on the old phone.
How can I track the uniqueness of a phone, and if the app has been installed on more than one device?
My goal isn't to control licensing, but rather to make sure the user knows what is "out there".
(My app stores private keys in the app container, and I want to ensure these keys don't fall into the wrong hands... hence the reason for my question)
UIDevice offers identifierForVendor
The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.
I'm aware if the following methods, each which has it'd flaws
UDID
Advertising Identifier
Vendor ID
The problem with UDID is that its deprecated and doesn't even work as of ios7, problem with other two is that the user can change them via software reset of phone or reinstallation of app
Another interesting solution I found is to randomly generate one yourself and then save to keychain to avoid deletion upon app reinstallation however would this work across software resets? And surely there's a very small chance that two devices would randomly generate the same ID?
I think the best option might be to use UDID but I would like to know if, even though the UDID is incorrect as of ios7, is it still unique?
Yet another option is MAC address but as far as I know, there is no API for these
Please advise on the best option
Starting iOS 7 deducing MAC address isn't possible. You can, however, use below:
[[[UIDevice currentDevice] identifierForVendor] UUIDString]
Per Apple Documentation:
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 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.
I'm experimenting a little with the identifierForVendor API.
As per the doc
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. Therefore, if
your app stores the value of this property anywhere, you should
gracefully handle situations where the identifier changes.
In Debug or Release with Ad Hoc, I cannot replicate this behavior. The identifier still remains the same even if I remove all the applications I have installed for the same vendor (the reversed domain name I'm using, e.g. com.test).
Is this can be observed only for App Store distribution? Am I missing something?
I'm running on a iOS 8.3.
Related question: iOS7 - Device unique identifier.
In Apple's documentation for [[UIDevice currentDevice] identifierForVendor], they state:
The value of this property is the same for apps that come from the same vendor running on the same device.
I take this to mean that if I have more than one app from me on a device, any of those apps should get the same value for this property across reinstalls of the app. But I'm not seeing that in debugging. I have a device with two different apps from me on it. I note the value in one of the apps, remove it, then reinstall it, and note a different value. Could this be because I'm debugging, or because there's something else going on? Can anyone confirm that this API does what it says it will? I've found at least one other post about problems here.
Further along in the same documentation:
The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.
From what I understand you install and app, remove it and reinstall it thus having deleted all the apps for a brief period of time which leads to a new identifier upon the next install.