简体   繁体   English

为什么iOS会在应用更新时获得新的identifierForVendor?

[英]Why does iOS get a new identifierForVendor when app updates?

Every time my app is updated from the App Store some small number of the users get a new identifierForVendor for some reason. 每次我的应用程序从App Store更新时,由于某种原因,少数用户会获得新的identifierForVendor My users don't sign up or login. 我的用户没有注册或登录。 They are all anonymous so I need to separate them through their vendor IDs. 它们都是匿名的,因此我需要通过供应商ID将它们分开。

I've considered that there could've been insufficient space on some devices, resulting in the app being deleted and reinstalled, but that's not the case since in the last update a friend of mine had over 2GB of empty space. 我认为在某些设备上可能没有足够的空间,导致应用程序被删除并重新安装,但事实并非如此,因为在上一次更新中我的一个朋友有超过2GB的空闲空间。

I know that the identifierForVendor is changed for a user who deletes and reinstalls the app. 我知道删除并重新安装应用程序的用户更改了identifierForVendor But that's not the case here, as the app is just updated. 但这不是这里的情况,因为应用程序刚刚更新。

What could the problem be? 问题是什么? The weird part is that this hasn't happened for development team devices yet. 奇怪的是,尚未发现开发团队设备。 Or there are still users who haven't experienced this bug after countless app updates, OS updates, etc. This only happens to a small percentage of the users. 或者仍然有用户在无数的应用更新,操作系统更新等之后没有遇到此错误。这只发生在一小部分用户身上。 All users are iOS7+ and it happens for different device models and iOS versions. 所有用户都是iOS7 +,它适用于不同的设备型号和iOS版本。

I use this code to get their ID: 我使用此代码获取其ID:

static let DeviceId = UIDevice.currentDevice().identifierForVendor.UUIDString

Then I save them into NSUserDefaults: 然后我将它们保存到NSUserDefaults中:

NSUserDefaults.standardUserDefaults().setBool(true, forKey: "User" + DeviceId)
NSUserDefaults.standardUserDefaults().synchronize()

Then I check if the user exists, at every new login: 然后我会在每次新登录时检查用户是否存在:

static func doesUserExist() -> Bool {
    var userDefaultValue: AnyObject? = NSUserDefaults.standardUserDefaults().valueForKey("User" + DeviceId)

    if defaultValue == true {
        println("Userdefaults already has this guy, moving on")
        FirstTime = false
        return true
    } else {
        println("First time in the app!")
        FirstTime = true
        return false
    }
}

If the user does exist it starts the login process. 如果用户确实存在,则启动登录过程。 If the user does not exist it shows them the signup process. 如果用户不存在,则向他们显示注册过程。 I am using Parse.com as backend and the deviceID is used as a username. 我使用Parse.com作为后端,deviceID用作用户名。 When that small amount of users experience this bug, I see a new username and a new account created. 当少量用户遇到此错误时,我会看到一个新用户名和一个新帐户。

There was a bug affecting the calculation of identifierForVendor when updating an app from app store between May and July. 在5月到7月期间从应用商店更新应用时,存在影响identifierForVendor计算的错误。 Apple has claimed they have already solved the issue and pushing another update should restore the original value before the critical date. Apple声称他们已经解决了这个问题并推动另一次更新应该在关键日期之前恢复原始值。 Reference: https://openradar.appspot.com/22677034 参考: https//openradar.appspot.com/22677034

Take note that some users still have observed this issue even updating weeks after July. 请注意,一些用户甚至在7月之后的几周内仍然观察到此问题。 So it is still possible that bug is still there for some or it could resurface anytime in the future. 所以仍有可能某些bug仍然存在,或者它可能在将来的任何时候重新出现。 So if you are using this data as part of your encryption, best is to save this to the keychain. 因此,如果您将此数据用作加密的一部分,最好将其保存到钥匙串中。

Save the vendorID in the KeyChain, that will persist after deletion or any update. 将vendorID保存在KeyChain中,该ID将在删除或任何更新后保留。

-(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 免责声明:我刚才接受了其他一些SO代码的答案, 所以我不记得有谁赞美,但最后不是我
@Jonny found the source @Jonny找到了消息来源

I'm confused why you're saving the IFV to NSUserDefaults first and then checking to see if that key exists. 我很困惑为什么你首先将IFV保存到NSUserDefaults然后检查是否存在该密钥。 I think you should... 我想你应该...

1) check NSUserDefaults first to see if the IFV key you created exists 1)首先检查NSUserDefaults以查看您创建的IFV密钥是否存在

2) if NSUserDefaults key does exist, great do what you need with it, this user's profile already exists 2)如果NSUserDefaults密钥确实存在,那么用它做得很好,这个用户的配置文件已经存在

3) if key does not exist, get the IFV and save it to NSUserDefaults 3)如果密钥不存在,请获取IFV并将其保存到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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在旧版本上更新新版本的应用程序时,identifierForVendor 发生了变化。 为什么? - identifierForVendor changed when updating new version of app on older version. Why? 当用户更新iOS应用程序时,应用程序:didFinishLaunchingWithOptions:被调用吗? - When a user updates an iOS app, does application:didFinishLaunchingWithOptions: get called? identifierForVendor是否会更改应用更新? - Does identifierForVendor change on app update? IdentifierForVendor在更新应用程序时会改变吗? - IdentifierForVendor will change when updating app? 即使我要求在后台更新位置,为什么我的iOS应用程序会被杀死? - Why does my iOS app get killed even though I ask for location updates in the background? 为什么在iOS 6中分配新图像时会调整UIImageView的大小? - Why does a UIImageView get resized when assigning a new image in iOS 6? 使用identifierForVendor是否会拒绝我的应用程序? - Does the use of identifierForVendor reject my app? 当应用暂停时,iOS8 CoreMotion从startActivityUpdatesToQueue获取更新 - iOS8 CoreMotion get updates from startActivityUpdatesToQueue when the app is suspended 即使暂停,也可以获取iOS应用的位置更新 - Get Location Updates for iOS App Even when Suspended 卸载设备上的ios应用后,如何在ios中保留identifierForVendor? - How to preserve identifierForVendor in ios after uninstalling ios app on device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM