iOS iCloud document change notification

347 Views Asked by At

Can you, in Swift get a change notification when a document in the apps's iCloud Drive container changes? For example I am testing a simple concept where I am storing all app data as a json string in the app's iCloud Drive container and I am loading it when the app launches. I can retrieve and save the json string on demand on multiple devices, but I am wondering if there is a way to get a change notification sent to an app when the file is changed on another device. If so, some direction would be appreciated.

1

There are 1 best solutions below

0
On

If you are using UIDocument, you can register for UIDocumentStateChangedNotification (for a particular document), otherwise if you are looking for changes in the App's iCloud container you need to use NSMetaDataQuery which is described in Discovering an App's Documents in Document-Based App Programming Guide for iOS