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
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.
Try to clear caches of app on your machine and then check. It may be your cache problem
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'
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.
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.
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.