Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to do one-way synching from a server-side database to iPhone?

I've got a database on my server which is about 3mb big. I'd like to ship that with my iphone application.

The most important thing is that I'd like to promote changes to the database (insert, updates, deletes) to the iphone. What's the best way of doing that? I mean - what is necessary on - the server - the client (= iphone) - between; how to transfer this data?

I'm pretty free in using technologies serverside; right now, I've got an sqlite-database on the server filled with the data I'd like to sync to the iphones.

like image 361
swalkner Avatar asked Jan 21 '10 11:01

swalkner


2 Answers

How often do you need the database to be updated, and how urgent are the changes?

If the database updates are infrequent and non-urgent, I'd have the app check for a new version of the database on startup, and if it has changed, download the entire new file.

The app would always download a small metadata file from a known URL on startup. The metadata file contains an version identifier for the latest version and a location where that version of the database can be downloaded. If the version identifier has changed from the version the app already has, will download the new version. If the version identifier has not changed, or if it can't check, the app can keep using the version it has.

Pro tip: if you want to show a progress bar for the download, include the size of the database in the metadata file. Cell networks often have transparent proxies that strip out the Content-Length header from HTTP responses.

like image 137
Will Harris Avatar answered Oct 02 '22 21:10

Will Harris


Try using web hooks.

The concept of a WebHook is simple. A WebHook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST.

A web application implementing WebHooks will POST a message to a URL when certain things happen. When a web application enables users to register their own URLs, the users can then extend, customize, and integrate that application with their own custom extensions or even with other applications around the web. For the user, WebHooks are a way to receive valuable information when it happens, rather than continually polling for that data and receiving nothing valuable most of the time. WebHooks have enormous potential and are limited only by your imagination! (No, it can't wash the dishes. Yet.)

You can find out more on Webhooks here: http://www.webhooks.org/ and http://webhooks.pbworks.com/

like image 21
feketegy Avatar answered Oct 02 '22 21:10

feketegy