I am trying to write data to the iCloud Keychain and have it replicate across devices using the same Apple ID.
If I install an app and call the following code, write an entry, and tun read, I see the data being read back to log on the current device.
However, if I install the same code on another device using same Apple ID, with iCloud/keychain switched on, I don't see the data if I attempt to read from keychain on that device.
I have tried enabling icloud and keychain sharing in capabilities to no avail.
Could someone point me in the right direction please?
-(void)writekc{
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"AppName" accessGroup:nil];
[keychainItem setObject:@"password" forKey:(__bridge id)(kSecValueData)];
[keychainItem setObject:@"username" forKey:(__bridge id)(kSecAttrAccount)];
}
-(void)readkc{
KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"AppName" accessGroup:nil];
NSString *password = [keychainItem objectForKey:(__bridge id)(kSecValueData)];
NSString *username = [keychainItem objectForKey:(__bridge id)(kSecAttrAccount)];
NSLog(@"Password:%@, User:%@",password,username);
}
In the end I have used SSKeyChain which has sync capability built in.