Why does iOS get a new identifierForVendor when app updates?

二次信任 提交于 2019-11-28 18:26:05

There was a bug affecting the calculation of identifierForVendor when updating an app from app store between May and July. Apple has claimed they have already solved the issue and pushing another update should restore the original value before the critical date. Reference: https://openradar.appspot.com/22677034

Take note that some users still have observed this issue even updating weeks after July. So it is still possible that bug is still there for some or it could resurface anytime in the future. So if you are using this data as part of your encryption, best is to save this to the keychain.

dogsgod

Save the vendorID in the KeyChain, that will persist after deletion or any update.

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

Disclaimer: I took the code from some other SO answer a while ago, so I don't remember whom to praise, but in the end it's not me
@Jonny found the source

I'm confused why you're saving the IFV to NSUserDefaults first and then checking to see if that key exists. I think you should...

1) check NSUserDefaults first to see if the IFV key you created exists

2) if NSUserDefaults key does exist, great do what you need with it, this user's profile already exists

3) if key does not exist, get the IFV and save it to NSUserDefaults

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if ([defaults valueForKey:@"IFV"]) {
    //this user already exists, do what you need to do next with IFV
}

else{
    //this is their first time using the app
    NSString *ifvString = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    [defaults setValue:ifvString forKey:@"IFV"];

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