【发布时间】:2019-08-31 01:22:30
【问题描述】:
我已经在 Android 和 IOS 中创建了一个应用程序。我是应用程序的最后一道障碍。我能够让 Android 用户与 IOS 用户一起工作,而 IOS 有一个 tableview。
现在我面临一个不同的问题。如果 iOS 应用程序上的“骑手”请求搭车并且 Android 驱动程序可用 - 我该如何完成这个用例?
如果iOS用户发出请求,流程如下:
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()
}
}
}
Firebase 条目如下所示:
我需要做的是让在线 Android 驱动程序接受/拒绝请求并按照步骤操作,就好像它是 Android Rider 与 Android 驱动程序一样。
如果 Android 请求搭车并按“请求”按钮,以下是步骤:
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();
}
运行上述代码时,它会打开位于驱动程序应用程序中的“客户呼叫”活动,驱动程序可以在其中接受/拒绝请求。
我怎样才能让请求从 IOS Rider 发送到 Android 驱动程序,就像它在 Android 到 Android 中的工作方式一样?
【问题讨论】:
-
您从项目设置中为同一个项目添加了 android 和 ios 应用程序?
-
在 Firebase 中是的
-
所以如果你共享同一个数据库,无论你使用什么平台都不会有任何问题
标签: android ios firebase firebase-realtime-database