Sync Mobile App and Web App without Third Party Services
We are currently creating a hybrid application . using Ionic Framework with PHP
for backend services
I have a case where a user has their profile in a web app and in a mobile app.
If a user adds two stories as favorites (their kind of reading app) from their mobile app or web app, how do I sync them?
Here are the scripts:
1) User marks favorite stories from web app, and when I go online via mobile app, display it.
2) The user marks favorite stories from the mobile app when offline (this will now be saved in LocalDB ). So again, when does it come online syncing with the server?
I know there are services like Firebase that provides syncing service
.
But what if I want to develop a Custom Syncing service myself for my application? Is this a very difficult process?
If so, and it can be developed, how should I proceed? Main idea? What are the best practices I should consider?
Any links would be appreciated?
source to share
I know some of the comments recommended by CouchDB in conjunction with PouchDB. This is a much better solution than trying to implement your own MySQL sync service.
However, since you are using the Ionic Framework, you can also use Couchbase. Take the following sample application:
https://github.com/couchbaselabs/TodoLite-Ionic
If you choose this solution, you will have three moving parts. You would replace MySQL with Couchbase Server and run Couchbase Sync Gateway to organize any data between the device and the server. You can save your PHP server if you have a web version of your application, as there is a PHP SDK for Couchbase.
Two entries can be found here:
http://blog.couchbase.com/using-couchbase-in-your-ionic-framework-application-part-1 http://blog.couchbase.com/using-couchbase-in-your-ionic-framework-application -part-2
In the long run, you will find that NoSQL is much nicer to work with when it comes to APIs and mobile devices than MySQL.
source to share
It can be helpful to write a POST method to the backend that receives data from your local application and some user data (session, access tokens, and other things that you think are urgent). On the body for the request, you include the data you want to sync. The backend takes the body. Parse it and return the result (http code) From this you can decide whether the application should delete local data or only mark it as synced in the local database
source to share