ios - Uber按钮不显示价格,只显示时间

标签 ios uber-api

这是我第一次使用 Uber api。我清楚地遵循了说明,但它从未真正提到如何在按钮中显示价格估算。我的代码神奇地显示时间(不知道为什么或如何)。请解释如何显示价格。服务器 token 和客户端ID都已集成在info.plist文件中。

ViewController 类:UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    let button = RideRequestButton()
    view.addSubview(button)
    button.center = view.center
    let ridesClient = RidesClient()
    let dropOffLocation = CLLocation(latitude: 20.301647, longitude: 85.819135)
    let pickUpLocation = CLLocation(latitude : 20.323706, longitude: 85.814981)
    let builder = RideParametersBuilder()
    builder.pickupLocation = pickUpLocation
    builder.pickupNickname = "Home"
    builder.dropoffLocation = dropOffLocation
    builder.dropoffNickname = "Mayfair Lagoon, Bhubaneswar"

    var productID = ""
    ridesClient.fetchProducts(pickupLocation: pickUpLocation) { (product, response) in
        productID = product[1].productID
        print("🥒\(productID)")
    }


    ridesClient.fetchPriceEstimates(pickupLocation: pickUpLocation, dropoffLocation: dropOffLocation) { (price, response) in

        print(price[0].estimate!,"🍚")
    }

    ridesClient.fetchTimeEstimates(pickupLocation: pickUpLocation) { (time, response) in
        print("🥕",time[0].estimate,"🥕")
    }


    builder.productID = productID

    button.setContent()
    button.rideParameters = builder.build()
    button.loadRideInformation()

}

最佳答案

Button 将深层链接到 Uber 应用程序,并且只会打开该应用程序。为了查看实时票价估算和上车 ETA 信息,您需要向其传递额外的参数。乘车请求按钮可以接受可选参数以将一些信息预加载到乘车请求中。您可以在 Uber documentation 中查看如何操作.这也解释了here在 GitHub 上

请查看 StackOverflow 线程 here . 解释并记录了如何管理此问题。

关于ios - Uber按钮不显示价格,只显示时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47855035/

相关文章:

ios - 自动核心数据迁移,如果我在源存储和目标存储之间有一些映射?

授权后,Uber-api 历史记录端点无法工作

python-requests - Uber API - 请求端点无法读取 json

swift - 请求乘车详细信息时获取零值 Uber

ios - 是否可以为 iPhone 设置本地主机 IP?

iOS:内存泄漏

ios - 将 plist 加载到我的 TableView 中后,如何将信息传递给第二个 View Controller ? (NS词典)

ios - 刷新 super token Swift

android - super 集成中的 Android 和 iOS 应用程序签名

ios - 在 iOS 中阅读短信