0

Hi I am developing small iphone application in which I want to generate unique id for my device. I am using following thing :

-(NSString*)uniqueIDForDevice
{
NSString* uniqueIdentifier = nil;
if( [UIDevice instancesRespondToSelector:@selector(identifierForVendor)] ) { // >=iOS 7
    uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else { //<=iOS6, Use UDID of Device
    CFUUIDRef uuid = CFUUIDCreate(NULL);
    //uniqueIdentifier = ( NSString*)CFUUIDCreateString(NULL, uuid);- for non- ARC
    uniqueIdentifier = ( NSString*)CFBridgingRelease(CFUUIDCreateString(NULL, uuid));// for ARC
    CFRelease(uuid);
}
return uniqueIdentifier;
}

So i tested this code locally. Mean Every time when I uninstall and install it again it will create same unique code for me. But when I push it to app store that time for every installation on same device it is generating different code. I want to generate same code for each installation on same device. Is there any method to do this. Need some help.

I want to generate a unique identifier for device which will be same for my device even I install and uninstall application many times. I am using OIS 7.0 version.

Thank you.

nilkash
  • 7,408
  • 32
  • 99
  • 176
  • possible duplicate of [how to identify ios device uniquely](http://stackoverflow.com/questions/19179799/how-to-identify-ios-device-uniquely) – dandan78 Aug 07 '14 at 11:15
  • In simulator also, each time reset the contents and settings then check the id is unique or not – Midhun MP Aug 07 '14 at 11:18
  • `identifierForVendor` is the recommended approach. I have heard that a UUID in keychain can survive across re-installs, but I haven't confirmed it – Paulw11 Aug 07 '14 at 12:02
  • I am using `identifierForVendor`. So then what I have to do? I have to store it in keychain. ? – nilkash Aug 07 '14 at 12:06

1 Answers1

1

The identifierForVendor changes only after a system restore, you can check some of my test here:iOS 7 access UUID value in an enterprise application (not for AppStore). In case of iOS version lower than ios6 you can save the id in the keychain, it will persist even after app uninstall

Community
  • 1
  • 1
Andrea
  • 26,120
  • 10
  • 85
  • 131