How CKSyncEngine synchronization works
mainThe synchronization lifecycle in this project follows this pattern:
- Initialization: On first launch, the app initializes a
SyncedDatabase(located inSyncEngine/SyncedDatabase.swift), which synchronizes a local store with the CloudKit server. - Local Changes: When a user performs an action (e.g., adding a Contact), the record is saved to both the local store and the server.
- Remote Notification: Saving a record to the server triggers a push notification.
- Remote Sync: The push notification instructs other devices to fetch the new records from the server. Once fetched, these records are saved to the local store, and the UI updates to reflect the new data.