SSKeyChain not retrieving accounts

579 Views Asked by At

I have two iOS applications (app "A" and app "B"), and I need to offer the user the posibility to access to app "B" with the login data stored in app "A" if the user is already loggued in app "A".

What I've done is to use the SSKeyChain library to store the login data of app "A" in the keychain. Something like this:

[SSKeychain setPassword:password forService:@"appA" account:username error:&error];

And then in App "B" I am retrieving this data in this way:

NSError *error;
NSArray *accounts = [SSKeychain accountsForService:@"appA" error:&error];

if (accounts.count > 0)
{
 // alert to the user
}

This is working perfect on the simulator, but this not working on my iPhone.

I already also added this line to my didFinishLaunchingWithOptions method:

[SSKeychain setAccessibilityType:kSecAttrAccessibleAlways];

Am I missing something?

1

There are 1 best solutions below

0
Viacheslav Kostechko On

Keychain is an encrypted container where you can store secured information like passwords,certificates,identities,…etc. In iOS, each Application has it’s own keychain. To share the data between apps, they should have the same Access Group in code signing entitlements.

Check out this tutorial

Looks like SSKeychain doesn't support access groups link

Probably you can try to use SGKeychain