UIDevice uniqueIdentifier deprecated - What to do now?

后端 未结 30 2218
日久生厌
日久生厌 2020-11-21 06:07

It has just come to light that the UIDevice uniqueIdentifier property is deprecated in iOS 5 and unavailable in iOS 7 and above. No alternative method or pr

相关标签:
30条回答
  • 2020-11-21 06:28

    I had got some issue too, and solution is simple:

        // Get Bundle Info for Remote Registration (handy if you have more than one app)
        NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
        NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    
    
        // Get the users Device Model, Display Name, Unique ID, Token & Version Number
        UIDevice *dev = [UIDevice currentDevice];
        NSString *deviceUuid=[dev.identifierForVendor  UUIDString];
    
        NSString *deviceName = dev.name;
    
    0 讨论(0)
  • 2020-11-21 06:29

    iOS 11 has introduced the DeviceCheck framework. It has a fullproof solution for uniquely identifying the device.

    0 讨论(0)
  • 2020-11-21 06:29

    For Swift 3.0 please use below code.

    let deviceIdentifier: String = (UIDevice.current.identifierForVendor?.uuidString)!
    NSLog("output is : %@", deviceIdentifier)
    
    0 讨论(0)
  • 2020-11-21 06:29
    + (NSString *) getUniqueUUID {
        NSError * error;
        NSString * uuid = [KeychainUtils getPasswordForUsername:kBuyassUser andServiceName:kIdOgBetilngService error:&error];
        if (error) {
        NSLog(@"Error geting unique UUID for this device! %@", [error localizedDescription]);
        return nil;
        }
        if (!uuid) {
            DLog(@"No UUID found. Creating a new one.");
            uuid = [IDManager GetUUID];
            uuid = [Util md5String:uuid];
            [KeychainUtils storeUsername:USER_NAME andPassword:uuid forServiceName:SERVICE_NAME updateExisting:YES error:&error];
            if (error) {
                NSLog(@"Error getting unique UUID for this device! %@", [error localizedDescription]);
                return nil;
            }
        }
        return uuid;
    }
    
    0 讨论(0)
  • 2020-11-21 06:30

    From iOS 6 onwards, we have NSUUID class which complies RFC4122

    Apple Link : apple_ref for NSUUID

    0 讨论(0)
  • 2020-11-21 06:31

    You can use your alternative for Apple UDID already. Kind guy gekitz wrote category on UIDevice which will generate some kind of UDID based on device mac-address and bundle identifier.

    You can find code on github

    0 讨论(0)
提交回复
热议问题