3

嗨,我想在我的 APP 上将 Ride 与 uber 按钮集成。我用参数向api发出了get请求

'server_token': 'ma***********************u',
'start_latitude',
'start_longitude',
'end_latitude' 
'end_longitude'. 

我得到了回应:

{
 "result": {
 "prices": [
    {
     "currency_code": "INR",
     "display_name": "uberGO",
    "distance": 18.45,
    "duration": 3503,
    "estimate": "₹559-720",
    "high_estimate": 720,
    "localized_display_name": "uberGO",
    "low_estimate": 559,
    "minimum": 60,
    "product_id": "c8170d76-b67c-44b1-8c26-5f45541434d2",
    "surge_multiplier": 2
  },
  {
    "currency_code": "INR",
    "display_name": "uberGO",
    "distance": 18.45,
    "duration": 3503,
    "estimate": "₹559-719",
    "high_estimate": 719,
    "localized_display_name": "uberGO",
    "low_estimate": 559,
    "minimum": 60,
    "product_id": "bc46ccfe-de64-4cad-b63a-7cf48e649a3e",
    "surge_multiplier": 2
  },
  {
    "currency_code": "INR",
    "display_name": "uberX",
    "distance": 18.45,
    "duration": 3503,
    "estimate": "₹834-1,069",
    "high_estimate": 1069,
    "localized_display_name": "uberX",
    "low_estimate": 834,
    "minimum": 80,
    "product_id": "4da6a747-e0be-4f56-a3c7-3f30f22bf86d",
    "surge_multiplier": 2.4
  },
  {
    "currency_code": "INR",
    "display_name": "uberGO",
    "distance": 18.45,
    "duration": 3503,
    "estimate": "₹834-1,069",
    "high_estimate": 1069,
    "localized_display_name": "uberGO",
    "low_estimate": 834,
    "minimum": 80,
    "product_id": "18656d0e-cc1b-4aa6-8146-92e605626caa",
    "surge_multiplier": 2.4
  },
  {
    "currency_code": "INR",
    "display_name": "uberXL",
    "distance": 18.45,
    "duration": 3503,
    "estimate": "₹1,646-2,099",
    "high_estimate": 2099,
    "localized_display_name": "uberXL",
    "low_estimate": 1646,
    "minimum": 125,
    "product_id": "2ea18da2-bcf0-4df7-a7b8-a827e9945322",
    "surge_multiplier": 3.4
  },
  {
    "currency_code": "INR",
    "display_name": "uberXL",
    "distance": 18.45,
    "duration": 3503,
    "estimate": "₹1,646-2,099",
    "high_estimate": 2099,
    "localized_display_name": "uberXL",
    "low_estimate": 1646,
    "minimum": 125,
    "product_id": "a4404842-e40a-471b-a7a5-13da3551e94f",
    "surge_multiplier": 3.4
    }
  ]
 }
}

现在我在按钮的 onclicklisteners 上添加了这段代码:

String uri = "uber://?client_id=eFrzgz_2Du2KYUXIi3MKaNOWtxo3i77K&action=setPickup&pickup[latitude]=37.775818&pickup[longitude]=-122.418028&pickup[nickname]=UberHQ&pickup[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103&dropoff[latitude]=37.802374&dropoff[longitude]=-122.405818&dropoff[nickname]=Coit%20Tower&dropoff[formatted_address]=1%20Telegraph%20Hill%20Blvd%2C%20San%20Francisco%2C%20CA%2094133&product_id=a1111c8c-c720-46c3-8534-2fcdd730040d";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
startActivity(intent); 


单击这些按钮时,它的按钮会重定向到具有正确 src 和 dst 的 uber APP,但它没有选择正确的 uber 类别,例如 UberX、UberGo、UberL 等。它始终选择默认类别。如何自定义它以使用户只需单击一个按钮即可预订出租车。

4

1 回答 1

1

用于 Android 的 uber-rides-sdk 中的深度链接测试使用的示例数据显示了与您发送的意图相同的参数,因此它应该可以工作。

uber:?action=setPickup&client_id=clientId&product_id=productId&pickup%5Blatitude%5D=32.1234&pickup%5Blongitude%5D=-122.3456&pickup%5Bnickname%5D=pickupNick&pickup%5Bformatted_address%5D=Pickup%20Address&dropoff%5Blatitude%5D=32.5678&dropoff%5Blongitude =-122.6789&dropoff%5Bnickname%5D=pickupNick&dropoff%5Bformatted_address%5D=Dropoff%20Address

在测试数据中,我看到它们还对键和值进行 URL/百分比编码(例如,pickup%5Blatitude%5D=32.1234),但是在文档中它们没有。
尝试对数据 URI 进行编码并重试。

也许您将意图发送到优步应用程序为时已晚?也就是说,在服务器上不再存在产品 id(优步汽车)之后,优步应用程序也不会选择它。

这些产品是从沙盒 API还是生产 API 端点返回的?

您能否首先通过向GET /v1/products/{product_id}发出请求来验证产品 ID,并确保您在响应正文中获得 200 OK HTTP 响应状态代码和正确的产品详细信息?

于 2016-02-29T21:10:24.910 回答