简体   繁体   中英

SSKeychain not retain data

I am using SSKeychain for storing UUID of device. However, sometimes SSKeychain not retains UUID, so my app has to recreate new UUID. Can someone tell me some reasons why SSKeychain not retains data.

Thanks in advance!

sorry for my english :)

Try this in your appdelegates for Objective C

NSString *uniqueId = [SSKeychain passwordForService:@"YOUR_PROJECT_IDENTIFIER" account:@"unique_id"];

if ([uniqueId length]==0)
{
      uniqueId = [AppDelegate uuid];
      [SSKeychain setPassword:uniqueId forService:@"Store credentials in Keychain Identifier" account:@"unique_id"];
}
[[NSUserDefaults standardUserDefaults] setValue:uniqueId forKey:@"iPhoneUniqueID"];
NSLog(@"Device_ID:%@",uniqueId);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM