iOS唯一码

+ (NSString *)getKeyChainValue {

    KeychainItemWrapper *keyChainItem=[[KeychainItemWrapper alloc]initWithIdentifier:@"LinkerApp" accessGroup:nil];

    NSString *strKeyChain = [keyChainItem objectForKey:(__bridge id)kSecValueData];

    if (strKeyChain == nil || [strKeyChain isEqualToString:@""])

    {

        [keyChainItem setObject:[Utils getUUID] forKey:(__bridge id)kSecValueData];

    }

    return strKeyChain;

}

 

+ (NSString *)getUUID {

    NSUserDefaults *standardUserDefault = [NSUserDefaults standardUserDefaults];

    NSString *deviceIdString = [standardUserDefault valueForKey:DEVICEID];

    if (deviceIdString == nil || deviceIdString.length == 0) {

        CFUUIDRef puuid = CFUUIDCreate( nil );

        CFStringRef uuidString = CFUUIDCreateString( nil, puuid );

        deviceIdString = (NSString *)CFBridgingRelease(CFStringCreateCopy( NULL, uuidString));

        CFRelease(puuid);

        CFRelease(uuidString);

        if (deviceIdString.length > 15) {

            deviceIdString = [deviceIdString substringToIndex:15];

        }

    }

    return deviceIdString;

}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。