如何获取设备唯一标识符?
一. 先从钥匙串里面读取
KeychainItemWrapper* wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"com.fansooxx.wk" accessGroup:nil];
NSString* device = [wrapper objectForKey:(id)kSecAttrAccount];
二. 判断是否读取到,如果没有,则写自己的生成算法,我这里直接用的uuid
if (device == nil || device.length == 0) {
NSString* uuid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[wrapper setObject:@"MY_APP_CREDENTIALS" forKey:(id)kSecAttrService];
[wrapper setObject:uuid forKey:(id)kSecAttrAccount];
device = uuid;
}
NSLog(@"%@",device);