Ensure identifierForVendor in iOS is unique for all devices?

| | August 6, 2015

In my project, I’m using identifierForVendor in iOS and storing it in the Keychain to define the iOS device.
How can I make sure that it is a unique ID for all iOS devices?

Here my code is:

-(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;

One Response to “Ensure identifierForVendor in iOS is unique for all devices?”

  1. This is not something that you have to worry about. Apple (in their API documentation) has guaranteed that it is unique per device per app. If it wasn’t, there would have been a lot of upset users and developers by now.

    Secondly, you don’t need to store it. It’s not going to change. Simply access it when you need it.

Leave a Reply