2

Already I built an iOS application that pull json data from a server(PHP MySQL), now i need to change this architecture to this schema to make my application work online/offline : enter image description here

there is any suggestion for solution for Auto Sync ?

HASNI Faiçal
  • 230
  • 3
  • 17
  • Good luck. Syncing means drinking. Two-way syncing is a complex problem, and the answers depend on many details of how your app works and what kind of data you have. – Tom Harrington Mar 09 '16 at 19:25

1 Answers1

1

Basically you need to follow the steps :

  1. Upon starting up, application:didFinishLaunchingWithOptions: you need to check for your internet connection. If not available, inform the user to enable it.
  2. After registering an internet connection you need to connect to your server and retrieve the json and map it to the database model. I suggest you use JSONModel to parse the json and MagicalRecord to easily save that data to your database.

That would solve all your needs for auto-sync.

Community
  • 1
  • 1
StefanS
  • 974
  • 1
  • 8
  • 35
  • thanks but i need to allow users to work with the application whene there is no connection or slow connection, and auto sync data whene internet comes back like auto sync with couchbase lite – HASNI Faiçal Mar 09 '16 at 10:55
  • then just register for notifications when the user connects to the internet with http://stackoverflow.com/a/3597085/1889814 and sync then.. -(void) checkNetworkStatus:(NSNotification *)notice ... – StefanS Mar 09 '16 at 11:00