Reputation: 1653
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 the same value every time.
NSString *strUniqueIdentifier = [[UIDevice currentDevice] uniqueIdentifier];
In iOS 7, the above method is returning different values and we are getting issues in user identification. iOS 7 provides the following alternate.
NSUUID *oNSUUID = [[UIDevice currentDevice] identifierForVendor];
[strApplicationUUID setString:[oNSUUID UUIDString]];
We replaced uniqueIdentifier
with identifierForVendor
, and created an Ad-hoc build. We then installed the build on both iOS 7 and iOS 6 devices. So far in iOS 7, we are getting the same value every time, but iOS 6 gives different values every time we delete and reinstall the app.
Upvotes: 31
Views: 50372
Reputation: 594
What is UDID replaced with?
For now it looks like Apple plan to replace UDID’s with two different identifiers: Vendor IDs and Advertising IDs.
Vendor IDs
ID that is identical between apps from the same developer. Erased with removal of the last app for that Team ID.
Advertising IDs
Unique to the device. Available to all applications; used for advertising — iAd has converted from UDID for iOS 6 and later. Reset with “Erase All Content & Settings”.
For the most part, Vendor IDs will allow developers with multiple apps to identify you as the same user across all their apps. This can help developers understand their audience better and provide a better service.
Advertising IDs will still create a unique identifier for the device but unlike the UDID, this can be turned off or reset, just as cookies can be controlled in the browser on your desktop or laptop.
With the announcement of iOS7 earlier this week, Apple took an additional step, which was to turn off another unique identifier — the “MAC Address” that app developers and advertising companies could use instead of the new Advertising ID. By closing this loophole, Apple is taking the good step of forcing these companies to only use a cross-app identifier that users can control.
What remains to be seen is whether the targeting companies will continue to seek ways around Apple’s mandate. Other technologies, like “device fingerprinting,” have been developed to uniquely identify your device outside of Apple’s framework. Whether Apple will crack down on these methods remains to be seen.
Upvotes: 8
Reputation: 4817
Use this little helper method to keep identifier in Keychain between install/delete sessions of app
-(NSString *)getUniqueDeviceIdentifierAsString
{
NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
NSString *strApplicationUUID = [SSKeychain passwordForService:appName account:@"incoding"];
if (strApplicationUUID == nil)
{
strApplicationUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:appName account:@"incoding"];
}
return strApplicationUUID;
}
Add the SSKeychain library to your project, e.g. via Cocoapods with pod 'SSKeychain'
Upvotes: 30
Reputation: 479
To add something to nerowolfe's answer, there is a great Keychain Wrapper named MCSMKeychainItem
, that, on top of several other things, allows you to generate and retrieve Unique Device ID with single line of code:
[MCSMApplicationUUIDKeychainItem applicationUUID];
so the basic usage will be something like
+ (NSString *)deviceId {
// load unique device ID or generate new one
return [MCSMApplicationUUIDKeychainItem applicationUUID];
}
It works on the basis of Keychain, where it stores once-generated unique identifier (as nerowolf suggested). It's open-source and you can download it here on github.
Note: I am not the author of the extension, nor do I in any way know him/her.
Upvotes: 0
Reputation: 15005
Try to clear caches of app on your machine and then check. It may be your cache problem
Upvotes: 0
Reputation: 14169
Are there additional apps from the same vendor installed on iOS7 devices? According to the docs:
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 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.
Do you provide the app via the AppStore? If not:
If the app was not installed from the app store (such as when the app is still in development), the vendor is determined based on the app’s bundle ID. The bundle ID is assumed to be in reverse-DNS format, and the first two components are used to generate a vendor ID. For example, com.example.app1 and com.example.app2 would appear to have the same vendor ID.
Upvotes: 2
Reputation: 8012
From the UIDevice Class reference for identifierForVendor
:
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.
Upvotes: 2
Reputation: 8081
If there are no other applications signed by you installed on the device, it is ok for identifier for vendor to change. Also, identifier for vendor may change if you install you application through different distribution methods, ie. application may not have the same identifier for vendor when installed through XCode and when distributed via TestFlight or HockeyApp.
Upvotes: 1