Real time syncing

ぃ、小莉子 提交于 2020-05-25 17:22:35

问题


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.

Thanks


回答1:


Push

  • 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.

Pull

  • Use NSURLSession to refresh your local DB with some regularity. This is very resilient to network failure.

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.




回答2:


The Most Simple way is to work with Firebase . Its No sql database and you will have instant update as you change anything .

This Video will guide you how speedy you can get update without any loop for refreshing data in application .

Ask me any help you need regarding Firebase .




回答3:


You can use silent push notifications to update your map with updated taxi locations.




回答4:


I would suggest you take a look at CloudKit. There are several reasons.

  1. If you decide to just build one app and somehow have driver functionality that is different from users (maybe by having drivers register and sign-in) then the app can post shared data to a public online database accessible to all users. You could use information in this scenario to post local notifications as the need arises.
  2. As iOS updates you will not be dependent on third party libraries
  3. If you decide to create a driver app and a separate user app, CloudKit will allow you to share data across these apps.
  4. Apple deals with the security and availability.
  5. Overall the process is very easy to implement.
  6. You can combine the local notifications with the public database to schedule reminders, alert users etc.
  7. CloudKit when done correctly will be essentially free. Just transfer CKAssets rather than raw data and your transfer/storage limits become negligible.
  8. You can also access your CloudKit databases from external web services/websites if you want to extend the data further.
  9. You can use CloudKit subscriptions to sync up user information automatically

NB - As pointed out in comments this is new technology. It is in the second generation and I prefer it because if one uses it creatively then you can simulate the external push notification behavior together with background support. CloudKit removes the need for a third party web server from which to push the external notifications (as the real notifications take place by writing to the shared database).

Check out my detailed answer on SO for sharing the data between apps with CloudKit. Here is a link to some CloudKit videos that further describe how CloudKit works. Apple has lots of documentation and sample projects available. You can review the developer website for more info on CloudKit.

CloudKit Quick Start



来源:https://stackoverflow.com/questions/33753698/real-time-syncing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!