Question

I tried to use SSKeychain to reserve UUID on iOS

and the sample code is below

NSString *retrieveuuid = [SSKeychain passwordForService:@"tempApp" account:@"tempUser"];
if (retrieveuuid == nil) {
    //Generate UUID
    CFUUIDRef cfuud = CFUUIDCreate(kCFAllocatorDefault);
    NSString *uuid = CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, cfuuid));
    //save in keychain
    [SSKeychain setPassword:uuid forService:@"tempApp" account:@"tempUser"];
    return uuid;
} else {
    return retrieveuuid;
}

My question is that I run the first app and then generate a UUID, and then run the second app which has the same parameters, so that the retrieveduuid should not be null, then why the second App returns a different UUID? I think that will return the same UUID as first app because I have saved the UUID in the keychain in App1 and try to retrieve it by the same parameters in App2.

Thanks for help

Was it helpful?

Solution

UUID is a Universally Unique IdenTifier. Would be kind of stupid if you got the same in two different apps, wouldn't it? ;)

If you want to share keychains between apps, see this question: How to share keychain data between iOS applications

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top