SSKeychain not retain data
Asked Answered
B

1

2

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 :)

Bursitis answered 12/10, 2016 at 4:39 Comment(5)
Did you use this method in appdelegates for create UUIDJaymejaymee
let userDefaults = NSUserDefaults.standardUserDefaults() if userDefaults.objectForKey("ApplicationIdentifier") == nil { let UUID = NSUUID().UUIDString userDefaults.setObject(UUID, forKey: "ApplicationIdentifier") userDefaults.synchronize() }Jaymejaymee
and one more suggestion create a new SSkeychain Certificate.Jaymejaymee
Thanks for your answer! But I wonder that, if we store UUID in NSUserDefaults, when user delete app, UUID will be also remove. so, we have to recreate a new UUID. I have been using SSKeychain open source library for storing UUID. I generated a unique device string and used the keychain to store. Through UUID, I can manage the number of devices that are using at a care center. Recently, the real number of devices is different with the number that I found in DB. So, I think that the UUID of some devices can not be get from SSKeychain and recreate new UUID.Bursitis
in iPhone some time thats problem face in some devices so in that case you can do as so in my answerJaymejaymee
J
1

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);
Jaymejaymee answered 12/10, 2016 at 7:12 Comment(7)
Thanks so much! br I wanna confirm , SSKeychain will be not retain data when:**br** 1. Changing team developer in my project.**br** 2. Download new provisioning profile. 3. Upgrade iOS or anything else?Bursitis
Download New Provisioning profile use that profile for SSKeychain . Hope your problem will be solveJaymejaymee
@user6407153 i have face same problem that you face and i made some changes that i tell you and my problem will be solve and i update my UUID method with above one. if your problem solve with my solution then approve my answer and give me up vote. thank you.Jaymejaymee
Thanks for your support! This is my first time I face this problem, my knowledge about SSKeychain is so bad. So, could you explain in detail for me how to put your code above in the project. <pre> [SSKeychain setPassword:uniqueId forService:@"Store credentials in Keychain Identifier" account:@"unique_id"]; <code> This string @"Store credentials in Keychain Identifier" mean what? one more, thanks so much!Bursitis
When you use this code inside - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { } that run that code and access your keychain from your project and your keychain password for particular development account .and i also new in SSKeychain so i dont help you more for this point . i am sorry about this .Jaymejaymee
Thanks for your support! :)Bursitis
Welcome @Bursitis is your problem solve then give up vote for my answer . Thank you.Jaymejaymee

© 2022 - 2024 — McMap. All rights reserved.