I am working on an Android app which is quite similar to Uber. The most important feature will be location tracking(real time driver's location on customer's device) and billing based on the distance covered and I am considering to use Firebase Cloud Function entirely for my backend.
Is it possible for do all the complex calculations (pricing, distance covered) in the backend? Is it a good idea to have this as backend for an app like this? What are the difficulties I may face in the long run?
With cloud functions you can implement the geofire library:
const GeoFire = require('geofire');
const geoDrivers = new GeoFire(admin.database().ref().child('geolocation'));
Geofire can not live inside a cloud function thus, for real time tracking you would have to load Geofire in the client side. By implementing geofire in cloud functions you would be able to calculate distance between point A and Point B, you will not be able to track movement between these two. You would be able to calculate price with the given distance between A and B.
Also by implementing geofire in cloud functions you will be able to query how many drivers are within a given location and you will not be notified whenever a new driver enters or exits the area of the query which is determined by the latitude, longitude and radius.