我正在使用以下代码获取UUID。在iOS版本10.2的相同设备上获取不同的UUID
-(NSString *)updateUserPhoneDetails{
NSString *retrieveuuid = [SSKeychain passwordForService:@"com.testUser" account:@"testUser"];
NSString *uniqueID;
if (retrieveuuid == nil) {
NSString *uuid = [[NSUUID UUID] UUIDString];
uniqueID=[uuid stringByReplacingOccurrencesOfString:@"-" withString:@""];
NSLog(@"Create new uuid : %@",uniqueID);
//Store the password in Keychain
NSError *error = nil;
[SSKeychain setPassword:uuid forService:@"com.testUser" account:@"testUser" error:&error];
}else{
uniqueID=[retrieveuuid stringByReplacingOccurrencesOfString:@"-" withString:@""];
NSLog(@"uniqueID : %@",uniqueID);
}
return uniqueID;
}
上述代码在iOS 10.0之前工作正常。 我已经测试iPhone 7,iPhone 5s,但获得一些时间不同的UUID。 我认为每当我重新安装相同的应用程序时,它应该是相同的。 请帮帮我。
[[NSUUID UUID] UUIDString];每次调用时都会生成唯一的ID,并且它不是特定于iOS的。 – Arasuvel
为什么要将它保存到钥匙串中?您只需将钥匙串保存一次,然后下一次只需要检索。无需每次更新钥匙串。 – Poles
我没有看到你的代码有什么问题。是否有可能从使用本地钥匙串切换到云钥匙串? – Sulthan