There are several functions that are performed using Firebase cloud functions. Before making changes in the functions or running the app, make sure you deploy the Firebase functions to your own firebase project.
Firebase functions can be used after you install Firebase-tools in your system globally
$ npm install firebase-tools -g
A firebase function can be deployed by running the command
$ firebase deploy --only functions
You can confirm the deployment of your functions by checking in the Firebase console. It will show you a list of all functions you deployed. For Taxi Booking Platform, it should show you total 5 functions as following
Once you deploy your functions, every function will get a unique URL for calling. Make sure you replace the existing function call URLs with these new URLs, otherwise the app will keep calling the old Firebase project only.
You can find out the existing Function URLs by searching for
https://us-central in the whole app. Replace all instances of old URLs you find.
To learn how to deploy a Firebase function in detail, check out our blog - Firebase Cloud function in Ionic 4
Following are the cloud function being used in Taxi Booking Platform
getDriver - This function is called when user books a ride. This function updates the user and Driver data to show that a ride is being requested. The response of this function is the driver's data.
rejectRide - When driver rejects a ride, this function is called. This updates user and driver records, showing that Driver is now available for new ride, and user can also book a different ride.
acceptRide - When driver accepts a ride, this function is called. This updates user and driver records, showing that Driver is now not available for new ride, and user can also not book a different ride.
drivernotRespond - When driver does not respond to a ride request for a specific amount of time set in the app, this function is automatically called. This function cancels the ride and shows an alert to the user that "Driver did not respond"
completeRide - This function is called when a ride is completed from Driver's side. This ends the ride for User and Driver both, updates their record to show that Driver is now available for a new ride and User can now book a new ride.
To know more about how to create, implement, deploy and test Firebase cloud functions, please refer to out blog - Firebase Cloud function in Ionic 4