0

This is my first time using Uber api. I followed the instructions clearly, but it never really mentioned how to display price estimate in the button. My code magically displays the time( dunno why or how). Please explain how to display price as well. Both server token and client ID have been integrated in the info.plist file.

class 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()

}

}

Sanket Ray
  • 1,071
  • 1
  • 15
  • 24

2 Answers2

1

Button will Deeplink into the Uber App and will simply open up the app. In order to see real-time fare estimates and pickup ETA information you will need to pass additional parameters to it. The Ride Request Button can accept optional parameters to pre-load some information into the ride request. You can see how to do it in the Uber documentation. Also this is explained here on the GitHub

Please, check out StackOverflow thread here. It is explained and documented how to manage this issue.

Miroslav T.
  • 161
  • 5
  • 1
    Just copying answers from another post doesn't help!...The other post you copied the answer from was my original post. – Sanket Ray Dec 22 '17 at 05:30
0

Please check it out below link

Display ETA and estimated money option for my "Ride there with Uber" button

Kanhaiya Sharma
  • 1,040
  • 8
  • 20