这是我第一次使用 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/