Can we access keychain items that are saved before enabling keychain sharing from app sharing same app group?

183 Views Asked by At

Can we access keychain items that are saved before enabling keychain sharing from app sharing same app group? If NO then what could be the best workaround?

1

There are 1 best solutions below

0
On BEST ANSWER

Before enabling keychain sharing all keychain items "accessGroup" is (AppIdentifierPrefix).bundleIdentifier, which is changed to (AppIdentifierPrefix).keyChainGroupName after turning it on.

Workaround is to remove all keychain items by accessing those through keychains.

AWSUICKeyChainStore *keychain = [AWSUICKeyChainStore keyChainStoreWithService:@"ServiceName"];
for (NSDictionary *dictionary in keychain.allItems)
    if ([dictionary[@"accessGroup"] isEqualToString:"(AppIdentifierPrefix).bundleIdentifier"])
        [keychain removeItemForKey:dictionary[@"key"]];