# Firebase Function in Code

{% hint style="warning" %}
This section is for the Ionic 4 version of this platform, where Firebase Functions were used to make the apps talk to each other. Ionic 5 version does not use Firebase Functions.
{% endhint %}

## Firebase Functions in Code

In the source code, Firebase functions are located in the User app in the `functions` folder

![](https://833912930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LqKtay1j36CbfXCRwWg%2F-LqL9K7IB-GZ_1nQsPY2%2F-LqLCax-O-ATpyNd2sgo%2FScreen%20Shot%202019-10-04%20at%203.29.46%20PM.png?alt=media\&token=85b15187-8f81-4811-9399-99b7013fe997)

There are five Firebase functions in-built currently

* **getDriver** - This function is called when User books a ride. This function finds a suitable driver and responds to User app, writes appropriate Data to `customer` and `driver` tables. Note, for demo purpose, the functions currently only looks for the driver who is logged in with the demo login (i.e. <admin@enappd.com>). You can change the logic here. <br>
* **acceptRide** - This function is called when Driver accepts an incoming ride request. This function writes appropriate info to `customers` table and gives back response to Driver app. User app receives a signal that driver has accepted.\
  \
  After this functions completion, driver can not accept new ride, and customer can not book new ride until ride is completed.<br>
* **rejectRide** - This function is called when Driver rejects an incoming ride request. This function writes appropriate info to `customers` table and gives back response to Driver app. User app receives a signal that driver has rejected.\
  \
  After this functions completion, driver can accept new ride, and customer can book new ride.<br>
* **driverNoRespond** - This function is called when Driver does not respond to an incoming ride request for a limited amount of time. This function writes appropriate info to `customers` and `drivers` table and gives back response to Driver app. User app receives a signal that driver is not responding.\
  \
  After this functions completion, driver can accept new ride, and customer can book new ride.<br>
* **completeRide** - This function is called when the Driver completes ride at destination. This function writes appropriate information to `customers` and `drivers` table. After this functions completion, driver can accept new ride, and customer can book new ride.
