[英]How to sync with local database data with online data when app is offline?
I want to build a mobile app where user can upload many tasks which will go to a server through API.我想构建一个移动应用程序,用户可以在其中上传许多任务,这些任务将 go 通过 API 到服务器。 after that All the uploaded tasks will be stored locally too.
之后所有上传的任务也将存储在本地。 Then user can assign all the tasks from pending to done offline(no internet).
然后用户可以将所有任务从待处理分配到离线完成(没有互联网)。 There will be a option where user can sync with all the done tasks which is stored locally to sync with the server to keep update with the pending and done tasks.
将有一个选项,用户可以与本地存储的所有已完成任务同步以与服务器同步以保持更新待处理和已完成任务。 How can i design this mobile app?
我该如何设计这个移动应用程序?
All you need is an api to be triggered when your application comes back online.您只需要一个 api 即可在您的应用程序重新联机时触发。
For syncing you can either use a sync adapter approach which is now deprecated.对于同步,您可以使用现已弃用的同步适配器方法。
Or you can use the latest WorkManager api which provide you with all options like time, internet connection, battery etc based runs and you focus would only be to write a job that runs calls this api.或者您可以使用最新的 WorkManager api,它为您提供所有选项,例如时间、互联网连接、电池等基于运行的选项,您只需编写一个运行调用此 api 的作业。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.