public void CreateRequest() { requestReference = Database.DefaultInstance.GetRootReference().GetChild("rideRequest").GetChildByAutoId(); newTripDetails.RideID = requestReference.Key; var locationNode = new NSDictionary ( "latitude", newTripDetails.PickupLat.ToString(), "longitude", newTripDetails.PickupLng.ToString() ); var destinationNode = new NSDictionary ( "latitude", newTripDetails.DestinationLat.ToString(), "longitude", newTripDetails.DestinationLng.ToString() ); var tripDetailsNode = new NSDictionary ( "location", locationNode, "destination", destinationNode, "destination_address", newTripDetails.DestinationAddress, "pickup_address", newTripDetails.PickupAddress, "rider_id", AppDataHelper.GetUserID(), "rider_name", AppDataHelper.GetFullName(), "rider_phone", AppDataHelper.GetPhone(), "created_at", newTripDetails.TimeStamp.ToString() ); requestReference.SetValue <NSDictionary>(tripDetailsNode); requestReference.ObserveEvent(DataEventType.Value, (DataSnapshot snapshot) => { //Driver has been assigned if (snapshot.GetChildSnapshot("driver_id").GetValue <NSObject>() != NSNull.Null) { if (snapshot.GetChildSnapshot("driver_id").GetValue <NSObject>().ToString() != "waiting") { if (!isDriverAccepted) { // Fetch Driver Details from the snapshot AcceptedDriver acceptedDriver = new AcceptedDriver(); acceptedDriver.ID = snapshot.GetChildSnapshot("driver_id").GetValue <NSObject>().ToString(); acceptedDriver.Fullname = snapshot.GetChildSnapshot("driver_name").GetValue <NSObject>().ToString(); acceptedDriver.phone = snapshot.GetChildSnapshot("driver_phone").GetValue <NSObject>().ToString(); isDriverAccepted = true; DriverAccepted?.Invoke(this, new DriverAcceptedEventArgs { acceptedDriver = acceptedDriver }); } // Gets Trip Status if (snapshot.GetChildSnapshot("status").GetValue <NSObject>() != NSNull.Null) { status = snapshot.GetChildSnapshot("status").GetValue <NSObject>().ToString(); } // Get fares if (snapshot.GetChildSnapshot("fares").GetValue <NSObject>() != NSNull.Null) { fares = double.Parse(snapshot.GetChildSnapshot("fares").GetValue <NSObject>().ToString()); } if (isDriverAccepted) { // Get driver location upadtes double driverLatitude = 0; double driverLongitude = 0; driverLatitude = double.Parse(snapshot.GetChildSnapshot("driver_location").GetChildSnapshot("latitude").GetValue <NSObject>().ToString()); driverLongitude = double.Parse(snapshot.GetChildSnapshot("driver_location").GetChildSnapshot("longitude").GetValue <NSObject>().ToString()); CLLocationCoordinate2D driverLocationLatLng = new CLLocationCoordinate2D(driverLatitude, driverLongitude); TripUpdates?.Invoke(this, new TripUpdatesEventArgs { DriverLocation = driverLocationLatLng, Status = status, Fares = fares }); } } } }); }