I have been using SSKeychain open source library for storing the data securely in my iOS app. Yesterday, I face an issue: SSKeychain wasn't able to retain its data when I updated my app from v1.0 to v2.0 from iTunes.
Code for UUID Generation :
- (NSString *)createNewUUID
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return (__bridge NSString *)string;
}
Over here, I generated a unique device string and used the keychain
to store the same and the app heavily depends on unique string/Device Identifier since from iOS5 to iOS7 there are lots of transformations done by Apple in concerned to Unique Device Identifier
, since the methods got deprecated.
Code snippet for Store & Retrieve :
NSString *retrieveuuid = [SSKeychain passwordForService:@"com.name.appname" account:@"AppName"];
if (retrieveuuid == nil) {
NSString *uuid = [self createNewUUID];
//Store the password in Keychain
NSError *error = nil;
[SSKeychain setPassword:uuid forService:@"com.name.appname" account:@"AppName" error:&error];
if ([error code] == SSKeychainErrorNotFound) {
NSLog(@"ID not found");
}
}
So, is this something that keychain won't be able to retain its values/identifier, when the app gets updated from Apple OR am I missing out at some point? Is it possible to store the Identifier permanently in device, without installing, uninstalling, resetting and updating the app?
Alternatively, is there any API, which can provide me the same deviceID/unique string when generated so need to store the Unique String?
Note : the app has to support iOS 4.3 and above.
SSKeychainErrorNotFound
, is this an extension you (or someone else) has made? – Sosa