gpt4 book ai didi

ios - Rides-ios-sdk - 获得最便宜的产品

转载 作者:行者123 更新时间:2023-11-28 15:35:52 29 4
gpt4 key购买 nike

我正在为 iOS 应用程序使用 Uber-SDK。在过去的几天里,我可以使用 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)
}

最佳答案

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

将此代码段复制到您的 Info.plist(右键单击并选择 Open As > Source Code)并将 YOUR_SERVER_TOKEN 替换为仪表板中的服务器 token (确保您使用与您的客户端 ID 对应的服务器 token )。

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

关于ios - Rides-ios-sdk - 获得最便宜的产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44275598/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com