Question

I am using this code to get the UDID of iOS 7 device in my app

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

But the same code in other applications shows another UDID. How can I get the unique identifier which will be the same throughout the iPad irrespective of the application?

Was it helpful?

Solution

You can't.

identifierForVendor will only give you the same identifier for apps from the same developer on that device. And it's not guaranteed to be permanent; if you delete all the apps from the vendor, and then reinstall them, it's likely you'll get a different identifier.

As for your iOS6 implementation, that's not going to give you anything permanent, as the point of a UUID is to give you a unique string every time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top