Search code examples
iosobjective-cswiftsskeychain

iCloud Keychain notify on update


I'm using the new iCloud Keychain feature implemented by SSKeychain. I set kcQuery.synchronizationMode = SSKeychainQuerySynchronizationMode.Yes to my passwords

Does iCloud Keychain now work? Will it be synchronized to my other iDevices?

How long does it take before my items will pushed to iCloud?

Is there a method which notifies me if new passwords reached my device?

Thanks!


Solution

  • I found a solution and answered in another question. SSKeychain: Accounts not stored in iCloud? - see at the bottom

    Does iCloud Keychain now work? Will it be synchronized to my other iDevices?

    Yes, if Settings > iCloud > Keychain is enabled

    How long does it take before my items will pushed to iCloud?

    Seems like instantly.

    Is there a method which notifies me if new passwords reached my device?

    No.


    Don't use the static methods of SSKeychain to write your credentials. Instead use SSKeychainQuery and set the synchronizationMode to SSKeychainQuerySynchronizationModeYes like this

    NSError *error; 
    [SSKeychain setAccessibilityType:self.keychainAccessibilityType];
    SSKeychainQuery *query = [[SSKeychainQuery alloc] init];
    query.service = service;
    query.account = account;
    query.password = password;
    query.synchronizationMode = SSKeychainQuerySynchronizationModeYes;
    [query save:&error];
    if (error) {
        NSLog(@"Error writing credentials %@", [error description]);
    }
    

    The static convenience methods on SSKeychain use the default synchronization mode SSKeychainQuerySynchronizationModeAny causing credentials not to be synchronized with the iCloud keychain.

    Additionally, make sure your devices have Keychain via iCloud enabled (Settings>iCloud>Keychain). You might also want to enable Keychain Sharing in your targets Capabilities.