Search code examples
cloudkit

NSUbiquitousKeyValueStore.didChangeExternallyNotification fires also when change is done on device itself


My app worked fine until iOS 16.0.

When I write to iCloud: NSUbiquitousKeyValueStore then the didChangeExternallyNotification notification is triggered also on the device I wrote to iCloud. So it did not change externally but internally. Therefore my app runs into a loop ;-(

Does anyone have the same issue?


Solution

  • I had contact with Apple and found at the you need to use 1 var:

    let defaultsAppGroup = UserDefaults(suiteName:"xxx")

    When using:

    UserDefaults(suiteName:"xxx").set()

    Multiple instances of UserDefault are made and therefore a didChangeExternallyNotification will be triggered to the other instances.