【问题标题】:Rides-ios-sdk - Get cheapest productRides-ios-sdk - 获得最便宜的产品
【发布时间】:2017-05-31 14:57:46
【问题描述】:

我正在将 Uber-SDK 用于 iOS 应用。在过去的几天里,我可以通过ridesClient.fetchCheapestProduct() 获得最便宜的产品。但是今天,该函数总是返回 nil 值。

这是服务器或 SDK 的问题吗?请帮我解决这个问题。 (我在越南,我的 client_id 仍然适用于 Android)

这是我的代码:

let ridesClient = RidesClient()
let button = RideRequestButton()

override func viewDidLoad() {
    super.viewDidLoad()

    let pickupLocation = CLLocation(latitude: 37.775159, longitude: -122.417907)
    let dropoffLocation = CLLocation(latitude: 37.6213129, longitude: -122.3789554)

    //make sure that the pickupLocation and dropoffLocation is set in the Deeplink
    var builder = RideParametersBuilder()
        .setPickupLocation(pickupLocation)
        // nickname or address is required to properly display destination on the Uber App
        .setDropoffLocation(dropoffLocation, nickname: "San Francisco International Airport")

    // use the same pickupLocation to get the estimate
    ridesClient.fetchCheapestProduct(pickupLocation: pickupLocation, completion: { product, response in
        if let productID = product?.productID { //check if the productID exists
            builder = builder.setProductID(productID)
            self.button.rideParameters = builder.build()

            // show estimate in the button
            self.button.loadRideInformation()
        }
    })


    // center the button (optional)
    button.center = view.center

    //put the button in the view
    view.addSubview(button)
}

【问题讨论】:

    标签: ios swift uber-api


    【解决方案1】:

    确保您设置了server token in your Info.plist。这允许RidesClient() 进行价格估算API 调用。

    将此 sn-p 复制到您的 Info.plist 中(右键单击并选择打开为 > 源代码)并将 YOUR_SERVER_TOKEN 替换为仪表板中的服务器令牌(确保使用与您的客户端 ID 对应的服务器令牌) .

    <key>UberServerToken</key>
    <string>YOUR_SERVER_TOKEN</string>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-22
      • 1970-01-01
      • 1970-01-01
      • 2021-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多