0

I'm developing a client for a webservice API, some of the data is persistent stored in a SQLite database.

is GCM a robust method to keep the data in sync ?

what I mean is, is GCM push notifications enough for keeping the data in sync or messages might get "lost" or the service might be unavailable ?

Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131

1 Answers1

4

GCM is primarily designed to serve as a "tickle" mechanism, to help you proactively realize that there is information for you to retrieve by some other means. While it is possible to pack more data than that in 4K payloads, GCM does not have any sort of reliability guarantees, timeliness guarantees, etc.

So, using GCM as an adjunct to polling to keep databases in sync seems perfectly reasonable. Using GCM as the sole delivery mechanism of database changes seems dangerous.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • how should I decide if old data need to be checked for updates on the server ? checking for updates every time the user view the data is pretty much against the idea of pushing instead of polling. – Gal Ben-Haim Oct 14 '12 at 13:00
  • @GalBen-Haim: "how should I decide if old data need to be checked for updates on the server ?" -- how am I supposed to know? I am not you. I did not write the app. I did not write the server. I have no idea what the "data" is, what is considered "old", or any of the business rules surrounding your app. – CommonsWare Oct 14 '12 at 13:06
  • its a theoretical question, let's say the SQLite database is supposed to be synced to a remote database. whenever something is changed on the remote server a GCM message is sent and the SQLite is synced. still, there might be a case where a message was lost or the service was unavailable. I'm talking about a case that data already in the SQLite database should be refreshed with new one. what can be an efficient way to know that ? the "dumb" way is to refresh all data when the user asks to view it.. – Gal Ben-Haim Oct 14 '12 at 13:33
  • I accepted your answer and opened a new question - http://stackoverflow.com/questions/12883089/strategy-for-syncing-android-app-database-with-a-remote-api – Gal Ben-Haim Oct 14 '12 at 14:21
  • I think sync adapter is solution for your answer. see this : http://stackoverflow.com/questions/10829371/sync-data-between-android-app-and-webserver https://developer.android.com/training/sync-adapters/running-sync-adapter.html – pathe.kiran Jun 08 '15 at 09:29