优步iOS SDK -如何实现自定义优步乘车请求按钮



我正在为iOS使用Uber SDK。如何在Swift中实现自定义优步乘车请求按钮?我不想使用Uber在他们的文档中使用的标准按钮。我想为它设计自己的UI。参考

您可以在swift中使用以下命令创建乘车请求按钮:

let button = RideRequestButton()
let ridesClient = RidesClient()
let pickupLocation = CLLocation(latitude: 37.787654, longitude: -122.402760)
let dropoffLocation = CLLocation(latitude: 37.775200, longitude: -122.417587)
let builder = RideParametersBuilder().setPickupLocation(pickupLocation).setDropoffLocation(dropoffLocation, nickname: "Somewhere", address: "123 Fake St.")
ridesClient.fetchCheapestProduct(pickupLocation: pickupLocation, completion: {
    product, response in
    if let productID = product?.productID {
        builder = builder.setProductID(productID)
        button.rideParameters = builder.build()
        button.loadRideInformation()
}
})

你想定制什么(产品、提货、送货)?根据您想要自定义的内容,您可以在这里的文档中看到示例:https://developer.uber.com/docs/rides/ride-request-buttons

如果您只想要深链接功能,您可以使用RequestDeeplink类。比如:

func setup() {
    let rideParameters = RideParametersBuilder().build()
    let deeplink = RequestDeeplink(rideParameters: rideParameters)
    let button = UIButton()
    button.addTarget(self, action: #selector(buttonAction), forControlEvents: .TouchUpInside)
}
func buttonAction() {
     deeplink.execute()
}

最新更新