I am stuck to a point, I am managing my app offline also. first time i get all profile data from a webservices and store its path into sqlite, I am facing problem in updating those data, like if images are changed how should I notify into my app, I searched it on Google and only solution is to send push notification to app when record is updated. What if user do not allow push notification?
Is there any other solution to manage app offline and update only when record is changed from online database?
implement offline mode in application
- put one extra column data_status in all table That indicate data is entered in local database is in offline or online mode. 1 for online and 0 for offline
- call API every-time with last response date and time on some frequent time interval(if required to update data frequent otherwise call when need) and API respond only changed or new data
when application is online
- call API and Store data in local data base with data_status = 1
and then display that data on screen from local database
- now when call again same API with server API response time and date and API respond only changed or new data.
when application is offline
- check app is offline then skip API calling function and fetch data from local database.
- now, when action perform on data like update insert. make that row data_status = 0
- when internet come check local data base which data is with data_status = 0 and call web service according that one by one, and getting success of each API make data_status = 1 and update row in local database.
Thank you
I would suggest to give Image Name base on timestamp
and unique userId
. like as below.
ImageName = yourUserId_timestamp.(111_1234567).
So Image name always be unique. so when you fetch date from server. first check that image is already exist in data base or not. if it is not then update image name with help of userId and store it. if it is then leave it.
Thanks
Nothing to change from your (application) side, your server guy can handle this flow. Whenever a new image will be upload, a new URL will be generated that you will for particular object. You can replace it in your local (simply update existing data).
You can use API's to check version of data cached in App. If updated version is available on server then you have to update local data with updated server data.