在线和离线管理iPhone应用程序 [英] Manage iPhone app both online and offline

查看:72
本文介绍了在线和离线管理iPhone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入了困境,我也在离线管理我的应用程序.第一次从网络服务中获取所有配置文件数据并将其路径存储到sqlite中时,我在更新这些数据时遇到了问题,例如,如果更改了图像,应如何通知我的应用程序,我在Google上进行了搜索,唯一的解决方法是发送记录更新时将通知推送到应用程序.如果用户不允许推送通知怎么办?

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?

推荐答案

在应用程序中实现脱机模式

  • 在所有表中额外增加一列data_status,指示在脱机或联机模式下在本地数据库中输入的数据. 1代表在线,0代表离线
  • 每次以一定的时间间隔调用API,最后一次响应的日期和时间(如果需要频繁更新数据,否则需要时调用),并且API仅响应已更改或新的数据

在线申请

  • 调用API并将数据存储在本地数据库中,并且data_status = 1 然后从本地数据库在屏幕上显示该数据
  • 现在再次调用具有服务器API响应时间和日期的相同API时,API仅响应已更改或新的数据.
  • 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.

应用程序离线时

  • 检查应用程序是否离线,然后跳过API调用功能并从本地数据库中获取数据.
  • 现在,何时对更新插入之类的数据执行操作.使该行data_status = 0
  • 当Internet到来时,检查数据为data_status = 0的本地数据库,并根据该数据库一个接一个地调用Web服务,并获得每个API的成功使data_status = 1并更新本地数据库中的行.

谢谢

这篇关于在线和离线管理iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆