实时同步 [英] Real time syncing
问题描述
我想开发与UBER相同的应用程序,在该应用程序中,我需要显示选定区域中的可用出租车,并随着出租车的出租,可用和不可用进行更新.一种自动刷新. 在固定的时间间隔后在后台调用Web服务不是一个好的选择. 任何人都可以建议我更好,更快捷的方法来实现这一目标.
I want to develop application same as UBER in which I need to show available taxis in the selected region and update as the taxis are hired, available, unavailable. Kind of auto refresh. Calling the web service in the background after regular time interval is not a good option. Can any one suggest me better and fast way to achieve this.
谢谢
推荐答案
推送
- Use sockets when the app is running. This will give you immediate updates.
- Use Push notifications when the app is not running (use notifications for critical changes), and ignore these notifications when the app is already running, in favor of sockets.
拉动
- 使用 NSURLSession 刷新本地数据库一些规律性.这对于网络故障非常有弹性.
- Use NSURLSession to refresh your local DB with some regularity. This is very resilient to network failure.
使用多种方法,因为速度和鲁棒性是互斥的.最终,您的目标是使本地数据库与服务器的数据库保持同步,并在数据更改时触发内部消息. 这是一项艰巨的任务,因此Firebase answer .
Use a combination of approaches, since speed and robustness are mutually exclusive. Ultimately, your objective is to keep your local DB in sync with your server's DB, and fire internal messages as data changes. No small task, hence the Firebase answer.
这篇关于实时同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!