iOS 7 showing different UDIDs in different applications

限于喜欢 提交于 2019-12-11 18:57:19

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/23109637/ios-7-showing-different-udids-in-different-applications

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!