Mobile Data Sync

I'm currently starting to develop a mobile application (iOS and Android) for an existing web platform. This web platform has a REST API, and the client application will use this for communication. The fact is that the mobile application can make changes to the API, and I must have offline support. This will have sync issues:

  • Clients can change the same data offline, and then can cause problems when synchronizing this information with the server

  • The web client can also change information, and the mobile client is offline and does not see changes, and also changes this old content

  • The presence of a mobile application for storing the latest data offline, so that the user can work. And when it comes to the network, it has to consider the changes and send the changes to the server

Are there any theoretical things that I can read or see algorithms that can be used for this? I mean, this is a very common occurrence for developing mobile applications, and I don't want to reinvent the wheel here.

+4
source share
2 answers

I recently wrote about synchronization ( a synchronization algorithm for exchanging data in the Client-Server model using the REST API ). The algorithm that I mentioned in the post is used to create synchronization functions to support offline clients. This can help you get some ideas with building synchronization logic for your specific requirements.

Note: the reason why I simply provide a link to the mentioned algorithm, rather than explain it, is because the message contains a lot of valuable comments that complement the article.

+3
source

To solve your problem, you can follow the approach below.

For example, you make changes through the web client. At this time, your mobile phone is disconnected. These changes are saved on the server. Now you have made changes to your mobile devices also offline. Here is the hard part to do. When your mobile phone goes online, first check if there are any changes made through the web client? if so, ask the user that "do you want to overwrite it with the latest changes?" like this kind of message or something else that you want to display in order to warn the user that the changes contradict each other.

If "Yes" is selected, go and add the changes made by your mobile phone.

Hope this helps you solve your problem.

0
source

Source: https://habr.com/ru/post/1499609/


All Articles