Search code examples
firebaseswift3firebase-realtime-databaseios10

Pass data from one app to another app using Firebase


I am developing an app that has two parts - Rider & Driver, like Uber. If the rider clicks on "request" and the driver "accepts" the request, I want to be able to have an alert pop up stating the driver has accepted your request.

Is there a way to pass data from one app to the other app and how would I attempt this?

I am also using Firebase as the database.

Edit

Firebase database:

enter image description here


Solution

  • This task can be easily accomplished with Firebase. You would need a Rider node and a Driver node.

    The rider would post a request to the driver's request node, which would notify the driver. If the driver accepts, that would be posted to the rider node who would be notified.

    Each driver would add a Firebase observer to their driver node and each rider would add an observer to their rider node.

    Drivers
      driver_01
        requests:
          rider_01: true
          rider_02: true
    
    Riders
       rider_01
         responses
          driver_01: false
       rider _02
         responses
          driver_02: true
    

    With the above structure, rider_01 has requested a ride from driver_01, and rider_02 has also requested a ride from driver_01.

    driver_01 declined rider_01 request but accepted driver_02 request.

    As the exchange occurs, riders and drivers receive events from Firebase which could then trigger a popup window.