Created
June 4, 2018 11:44
-
-
Save zhangkn/0ea9eb3fbfe33ae16b4e11da066703dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)openUDID{ | |
if (_openUDID == nil || [_openUDID isEqualToString:@""]) { | |
KNKeychainItemWrapper *wrapper = [[KNKeychainItemWrapper alloc] initWithIdentifier:@"kn.openUdid"accessGroup:nil]; | |
// 读测试 | |
NSString *openUDID = [wrapper objectForKey:(__bridge id)kSecValueData]; | |
NSLog(@"读出_openUDID:%@",openUDID); | |
if (openUDID == nil || [openUDID isEqualToString:@""]) | |
{ | |
openUDID = [OpenUDID value]; | |
// 如果是模拟器 | |
if (TARGET_IPHONE_SIMULATOR){ | |
}else{ | |
[wrapper setObject:openUDID forKey:(__bridge id)kSecValueData]; | |
} | |
NSLog(@"写入_openUDID:%@",openUDID); | |
} | |
_openUDID = openUDID; | |
NSLog(@"_openUDID:%@", openUDID); | |
} | |
return _openUDID; | |
} | |
//存储设备ID的例子 | |
// 是否刷机/还原 是否卸载重装APP 获取方式及优先级 | |
// 否 是 KeyChain、Safari Cookie、iCloud、IDFA、IDFV、NSUUID | |
- (NSString *)strUUID{ | |
if (_strUUID == nil || [_strUUID isEqualToString:@""]) { | |
KNKeychainItemWrapper *wrapper = [[KNKeychainItemWrapper alloc] initWithIdentifier:@"kn_keyid"accessGroup:nil]; | |
// 读测试 | |
NSString *strMD5 = [wrapper objectForKey:(__bridge id)kSecAttrAccount]; | |
NSLog(@"读出md5:%@",strMD5); | |
if (strMD5 == nil || [strMD5 isEqualToString:@""]) | |
{ | |
strMD5 = [MD5Generator MD5]; | |
// 如果是模拟器 | |
if (TARGET_IPHONE_SIMULATOR){ | |
}else{ | |
[wrapper setObject:strMD5 forKey:(__bridge id)kSecAttrAccount]; | |
} | |
NSLog(@"写入MD5:%@",strMD5); | |
} | |
_strUUID = strMD5; | |
NSLog(@"strUUID:%@", strMD5); | |
} | |
return _strUUID; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment