Reputation: 530
The title basically says it. I have an application which is usable as a web app anda mobile app. The mobile app receives and sends data to the server. There are several cases to cover when doing a sync but I need to somehow know which is the most current edit. I plan to sync at start and stop of the mobile app. The most difficult case is probably when the user starts the app without internet and closes it still not having internet. How to solve this?
Please note that timestamps are useless since you are on a mobile device where the clock might be changed by the user.
What would you suggest? I don't want to ask the user about conflict solving but implement some automation. (Just take the most current one)
Thanks
Upvotes: 1
Views: 108
Reputation: 13570
Try http://www.couchbase.com/communities/couchbase-lite. It's an embedded NoSQL store for iOS and Android, which is able to sync with CouchDB and Couchbase Server.
Upvotes: 1
Reputation: 138
I beg to differ : how long ago is quite risky. For example some countries have a daylight saving time
I think you should look into ready to use solution like couchdb( and his sqlite cousin :pouchdb): you can make explicit or implicits synchronisation, and there's quite a work done for solving conflicts http://guide.couchdb.org/draft/conflicts.html
Upvotes: 1
Reputation: 2178
timestamp isn't useless, you just need to rethink how you use it. In this case the servers time is god. when the mobile device establishes contacts the server, the mobile can let the server know how long ago from now the data in question was created. Then once the information is transferred the server knows to set the time for that data as the current time on the server minus the amount of time that provided by the mobile.
So for example:
This way the time for the 9am data will be correct regardless of the time on the mobile device.
Upvotes: 4