Reputation: 2530
I have created an app in both Android & IOS. I am on the last hurdle of the app. I was able to get Android user working with IOS user whereas the IOS had a tableview.
Now I am faced with a different problem. If the "rider" on the iOS app is requesting a ride and the Android driver is available - how can I finish this use case?
If the iOS user makes a request, this is the process:
func requestPressed(_ sender: Any) {
print("... requestPressed")
let dict = selectedPin!.addressDictionary
if dict?.count == 0 {
// this isn't shown to the user, just in your debug window
print("no addresses available, try again in a few seconds")
return
}
destAddress = selectedPin!.addressDictionary!["Street"] as? String ?? "None"
if destAddress == "None" {
print("no valid address available, try again in a few seconds")
return
}
if userLocation != nil {
print("my userLocation: \(userLocation!)")
if canRequestRyde { // if true ...
// get the destination area name, and the price
areaNameDestination = DriveHandler.Instance.getAreaName(latitude: destLat, longitude: destLong)
print("destination area \(areaNameDestination)")
requestFarePrice()
rRideHandler.Instance.requestRide(latitude: Double(userLocation!.latitude), longitude: Double(userLocation!.longitude), destLat: Double(destLat), destLong: Double(destLong), currentAddress: self.currentAddress, destAddress: destAddress, farePrice: farePrice)
// reset the driver message
driverMessage = ""
canRequestRide(delegateCalled: true, request: nil)
} else {
riderCancelled()
}
}
}
The Firebase entry would look like this:
What I need to do from this is for the online Android Driver to either accept/decline the request and follow the steps as if it was Android Rider vs Android Driver.
Below are the steps if Android requests a ride and press "Request" btn:
private void requestPickupHere(String uid) {
Log.e(TAG, "requestPickupHere");
DatabaseReference dbRequest = FirebaseDatabase.getInstance().getReference(Common
.request_tbl); // "RideRequests"
GeoFire mGeoFire = new GeoFire(dbRequest);
mGeoFire.setLocation(uid, new GeoLocation(Common.mLastLocation.getLatitude(),
Common.mLastLocation.getLongitude()));
// write to db
if (search_bar_destination != null) {
dbRequest.child(uid).child("destination").setValue(search_bar_destination);
} else if (tap_on_map_destination != null) {
dbRequest.child(uid).child("destination").setValue(tap_on_map_destination);
}
dbRequest.child(riderId).child("status").setValue("");
if (mUserMarker.isVisible()) {
mUserMarker.remove();
}
// Add a new marker
mUserMarker = mMap.addMarker(new MarkerOptions()
.title("Pickup Here")
.snippet("")
.position(new LatLng(Common.mLastLocation.getLatitude(), Common.mLastLocation.getLongitude()))
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
mUserMarker.showInfoWindow();
btnRequest.setText("Getting your DRIVER ...");
location = getCompleteAddressString(Common.mLastLocation.getLatitude(), Common.mLastLocation.getLongitude());
Log.e(TAG, "riders location = " + location);
findDriver();
}
When the above code is run, it open an activity "Customer Call" located within the Driver Application, where the driver can either Accept / Deny the request.
How can I get the request to be sent from IOS Rider to the Android Driver in the same way it would work for Android to Android?
Upvotes: 0
Views: 99
Reputation: 80914
Using different platforms shouldn't be an issue, when a user requests a ride then you can add an attribute under the driver in the database for example:
DriverRides
DriverId
Name: peter
purpose: needs a ride
Then you can retrieve all the requests to be appear for that driver in a recyclerview
. It shouldn't matter what phone the user is using, except if you want the android user to take requests and the ios user to send requests.
You are using the same database for both platforms, so when an ios user or android user store data it will go to the same place. For example if user x uses an iPhone and user y uses a Samsung, you would do the following in the database:
Users
UserId1
name: userx
age: 100
UserId2
name: usery
age: 120
Upvotes: 1