Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS7 - Device unique identifier [duplicate]

Tags:

Our iOS application is for specific users. So, we used device unique identifier for user identification. This approach works fine till iOS 6, because we are getting same value every time.

NSString *strUniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier]; 

In iOS 7, above method is retuning different values and we are getting issues in user identification. iOS 7 apis provide following alternate.

NSUUID *oNSUUID = [[UIDevice currentDevice] identifierForVendor]; [strApplicationUUID setString:[oNSUUID UUIDString]]; 

I replaced "uniqueIdentifier" with "identifierForVendor", and created Ad hoc build. Installed build on both iOS 7 and iOS 6 devices. In iOS 7, so far, i am getting same value every time, but iOS 6 gives different values every time, when we delete and reinstall app.

Currently application is not available on App store. So i am not sure how this api works for App store build.

Questions: 1) For appstore app, is "identifierForVendor" return same value for iOS 7 every time? or it may change when user delete and reinstall app in future? 2) Is any other alternative available for "unique identifier" in iOS 7 apis, which return same values for both iOS 6 and 7? 3) Any other suggestions...

like image 302
furqan kamani Avatar asked Sep 25 '13 19:09

furqan kamani


2 Answers

3) Any other suggestions...

You should consider strategies for identifying and authorizing the user instead of the device. Depending on a device-specific identifier prevents authorized users from switching devices without some sort of administrator interaction, and allows non-authorized users access if they happen to find/steal/borrow an authorized device. You can avoid these problems by relying on user credentials instead of device identifiers.

like image 25
Caleb Avatar answered Sep 23 '22 14:09

Caleb


As you can see in the documentation here:

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.

In short, the identifier for a particular vendor will remain the same if at least one app by that vendor remains on the device. Once there are no more apps left (or in the case of a single app, it is reinstalled), the identifier can and will change. As far as I know, there should not be a difference on iOS 6 vs iOS 7, so any difference you are seeing is coincidental.

like image 172
Dima Avatar answered Sep 19 '22 14:09

Dima