Reputation: 7373
Reviewed lots of questions as there are number of questions with same topic but not find with the same issue so posting.
Issue
Looking to Generate Unique Identifier
for iOS
Device as if user install app and with reinstall generate same identifier.
Resolved But Not Working With 64 Bit Devices
I Used this code for fetching the unique identifier for iOS
device and it works fine all but when i run it on 64 bit iOS device
it gives different result on every install. Please review if anyone know about the possible solution.
- (NSString *)GetUUID {
@try {
UIDevice *device = [UIDevice currentDevice];
return [[device identifierForVendor]UUIDString];
}
@catch (NSException *exception) {
return @"00000-00000-0000-00000";
}
}
Upvotes: 1
Views: 377
Reputation: 4846
Use keychain Access to solve getting different vendor ID
Simple iPhone Keychain Access
http://useyourloaf.com/blog/2010/03/29/simple-iphone-keychain-access.html
Upvotes: 0
Reputation: 4817
For storing identifier betweeen reinstalls you may use this code (add SSKeychain to project)
/*
The following method determines the AppName and a uniqueidentifier and store it in the keychain
As a result when the user removes the app, downloads it again his JID and password which are derived from the
uniqueidentifier don't change.
otherwide the identifierForVendor method would return a new value on reinstall
*/
-(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;
}
Upvotes: 0
Reputation: 69479
The identifierForVendor
will stay the same as long as app from the same developer(vendor) are installed on the device.
Thus if user uninstalls your app and there are no other app by you on the user device the identifierForVendor
will be different when the user re-installs you app.
Apple has made it very clear they don't want developers track devices or installs per device. Thus you can no longer get any unique identifier from the device.
The changing of the identifierForVendor
could have to do with some re-installing isseu. I've been tracking identifierForVendor
and dit not see this issue.
Upvotes: 1