Reputation: 729
I'm currently working on a project that uses CoreData
for data saving in swift, and for the purpose of synchronization I wanted to use iCloud, and the first thing I thought was on the CoreData iCloud
implementation, but since it's now marked as deprecated I started using CloudKit
, and everything works fine until I try to make a backup of the information after an internet connection is stablished (in case of failure when the information should be updated), the app does not store files, just data, all CKRecords
are working fine.
My questions are:
CloudKit
connect to the automatic iCloud synchronization, the one that happens when the device is plugged and has an internet connection.The current structure is:
CoreData
for local saving and withdrawal of data, and CloudKit
for Cloud synchronization.
So far I understand that: CloudKit
does not interact directly with CoreData
and all actions involving data synchronization must be done with the Api calls.
Thank you for your help and if I forgot something please let me know.
Upvotes: 1
Views: 451
Reputation: 3932
1) When your app is terminated it isn't running so you can't sync anything. You would need to re-launch your app (possibly into the background?), but there are some serious limits to what you can do to have that happen without user intervention. Here's a couple threads that might shed more light: Launch app in background automatically? and Will iOS launch my app into the background if it was force-quit by the user?
2) Out of the box CloudKit doesn't do anything 'automatically', it does what you tell it to do. You will need to set it up to fire at appropriate times in your code (when something changes), and in response to push notification for changes from other devices.
Upvotes: 1