1

i'm writing an app that manage a sqlite database, and i have write a web server, i want the user register in my web server with username and password, i already know how make a request from ios app to server and receive the response, but i want enable also the synchronization of the sqlite database to other device, i now that with core data i can use iCloud synchronization, but for now i prefer use sqlite, and find a way to synchronize it, for example i want create this:

  1. make a change in the sqlite in the iPhone app;
  2. the app send this change to the server for that user;
  3. then the server have to send this update to other device connected at that user;

and now i can't go over, how the server can send this change to the other device? the device has to be always listen to the server? or there is a way to send this update directly to some device and handle it? like an apple push notification?

EDIT: if it's possible use an apple push notification to do this, i doesn't want alert with text sound and badge the user, but send a "silent notification" it's possible?

1 Answer 1

1

As a high-level there are a few different ways to approach this, all of which have pros and cons. Two name two examples you can do a polling method, active push or a hybrid approach.

Polling: at some pre-determined interval the app tries to "phone home" and send the delta db changes up to the server. Here you know that your server will be expecting X number of responses in any given interval so you can appropriately gauge your load.

Active Push: The user decides when they want those changes to be transmitted to the server by hitting a "Sync" button. This allows the user to only push data back up to the server when they know there's a change but an over zealous user may make a change, upload, make a change, upload, etc instead of queueing up a bunch of changes and sending them all at once. This may create frequently unneeded server calls.

Hybrid: You setup a polling schedule within the app AND give the user the ability to Sync at-will in the event there is a critical change that needs to be made ASAP.

Regarding the listener side of the equation you face a similar challenge conceptually. If the original user makes 20 changes and presses Sync 20 times do you bombard the second user's device 20 times as well or do you queue those changes up and send them down every 5 minutes (as an example)? Unless you have both devices paired to each other or are connected to the same network AND visible to each other via your app you're going to need to leverage that back-end server. Push notifications can be very useful in this manner but there is extra development and setup overhead to take into account to properly implement them.

To boil this all down I would recommend laying out what YOU want your syncing model to look like before you start marching down a path.

8
  • thanks for the answer, i doesn't like that the user press a "sync button", i prefer the way of push notification, you know how i can send a push notification from the server to the app? to change the content? some way to start?
    – Piero
    Jul 31, 2013 at 14:19
  • You're going to want to search around for how to implement an APNs server. There are a bunch of open-source examples out in the world so you maw want to start there.
    – Dan
    Jul 31, 2013 at 14:30
  • thank you very much again, last answer, can you give me some link example of this open source example apns server? i find only parse.com and other payment service...
    – Piero
    Jul 31, 2013 at 14:40
  • but you are talking about Apple push notification? but i can't use the apple push notification because when arrive to the device show an alert view, so every time one device make a change the other receive always an alert view...
    – Piero
    Jul 31, 2013 at 14:46
  • Push notifications don't always trigger alert views. You can configure them to do so but it's not a requirement - just pass NULL as the Body and Sound. You can also pass NULL as the Badge if need be. Tutorial: blog.serverdensity.com/… Server Code: code.google.com/p/apns-php
    – Dan
    Jul 31, 2013 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.