Home How to handle offline mode with CoreData and CloudKit?
Reply: 0

How to handle offline mode with CoreData and CloudKit?

user1438 Published in May 20, 2018, 10:06 am

I am building a simple app similar to Notes app by Apple, my app uses CoreData and CloudKit. Currently I am stuck with few problems related to network availability with CloudKit.

When network is available, everything goes well, CoreData saves the notes and CloudKit does too using CKModifyRecordsOperation. However, when network is absent, the app somehow keeps the operations sent while offline and pushes them the cloud when the application goes online. But, it only does when I create another operation and added to the queue, it does not do it automatically when the application become active (I brought the app from background to active mode and waited 5mins, nothing happened. Only when I queued another operation, then all pending operations were sent too)

My question here is, how to trigger the app to sent all pending operations without creating another operation?

Of course above is possible if the user didn't kill the app (Double home button then swipe away). How to handle such case? when few records created while offline and then app got killed.

I thought of flagging each record in CoreData that was successfully synced, then every time the app launches, go through those which were not synced and sync them.

Is this the right way? or Apple already have a better way to handle this and I still can't find it?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299796 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO