Real time syncing
Asked Answered
H

4

8

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

Hornback answered 17/11, 2015 at 9:48 Comment(1)
You have to remember that UBER uses 2 applications. One public and one for the driver. I don't know exactly how they are doing the sync, but I would go for Driver App -> update position to server -> server send silent push with information to registered public app near the location.Inattention
S
9

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.

Stasiastasis answered 4/12, 2015 at 0:3 Comment(2)
I really like your approach and want to build something similar but not for taxis. What do you mean by a "local DB"? Are you referring to use something like CloudKit?Benz
More like couchbase.com, designed to keep client & server in sync. Couchbase Server 4.5 enables you to create mobile apps that provide a great user experience by accessing a local, embedded database that automatically synchronizes with the cloud.Stasiastasis
M
0

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 .

Monosepalous answered 3/12, 2015 at 12:21 Comment(2)
I think the question is: how does Firebase notify the devicesStasiastasis
The answer is the way XMPP works (SOCKETS) . I just show you the easy way Firebase .Monosepalous
H
0

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

Historic answered 4/12, 2015 at 2:31 Comment(1)
I would agree with CloudKit (but one can argue that I have vested interest since I posted my own answer), yet I feel that if it is as responsive as iCloud, it is anything but reliable. Please prove me wrong.Stasiastasis
N
0

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

Neuburger answered 4/12, 2015 at 6:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.