问题
My requirement is for a UDID that persists across device reboots, OS updates, app re-installs, and device resets (ie the user chooses Settings > General > Reset).
I'm not trying to breach any security on the device; this is for a financial app.
As I understand it, OpenUDID is deprecated. I have not figured out whether SecureUDID is useful, given that users can opt out and for security reasons.
The advertiser ids and vendor ids are not persistent.
Saving an ID in keychains or user defaults/preferences does not seem to meet my requirements: those mechanisms don’t appear to be persistent enough (as stated above).
Does anyone have any suggestions? Or has Apple just made this impossible for their mobile devices?
Any help would be much appreciated.
回答1:
The official replacement for -[UIDevice uniqueIdentifier]
, according to the docs, is 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.
Obviously this isn't an issue for you, since you're only creating one app. However, this property does have a few limitations:
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 other words, this identifier is almost like a UDID, with the one limitation that when the user deletes all of the apps made by you from their device, this identifier will be reset. But honestly, I can't see any reason why this isn't good enough for the average app. The only case in which identifierForVendor
gets reset only when the app is deleted and reinstalled. It persists across reboots, software updates, etc., so it shouldn't really be an issue.
TL;DR what you are asking for is not currently technically possible without violating Apple's rules, but identifierForVendor
really should be a good enough replacement. I can't think of a single legitimate reason why you would need an identifier that persists across app deletions and device resets.
来源:https://stackoverflow.com/questions/17561938/is-there-a-persistent-replacement-for-udid