uber/uber-ios-sdk

Request Ride Button in iOS

Opened this issue · 13 comments

Hello,

We have added the request ride button to our app in iOS and Android. In Android is working fine because the app shows the ETA and best service available but the iOS app doesn't.

Those are the problems that we have:
- We added the button in a subview to position in where we wanted. Because the button could not be moved in the storyboard. Is this the correct procedure? I tried to do with the center property of the button via code but the button was centered and too high in the view.
- I added the code as stated in the documentation but no ETA time is showed and no service by default. I'm using Xcode Version 8.2 (8C38) and Swift 3.

This is the code I use to show the button:

func showUberButton(){

	let latitudeDropOff : CLLocationDegrees = Double(self.selectedUbicacion.latitude)!
	let longitudeDropOff : CLLocationDegrees = Double(self.selectedUbicacion.longitude)!
	// set a dropoffLocation
	let dropoffLocation = CLLocation(latitude: latitudeDropOff, longitude: longitudeDropOff)
	let pickupLocation = CLLocation(latitude: self.currentPosition.latitude, longitude: self.currentPosition.latitude)
	
	//make sure that the pickupLocation is set in the deeplink
	let builderETA = RideParametersBuilder()
		.setPickupLocation(pickupLocation)
		// nickname or address is required to properly display destination on the Uber App
		.setDropoffLocation(dropoffLocation,
		                    nickname: self.selectedUbicacion.information)
	
	// 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
			builderETA.setProductID(productID)
			self.rideButton.rideParameters = builderETA.build()
			
			// show estimate in the button
			self.rideButton.loadRideInformation()			}
	})
	
	
	vMapa.addSubview(uberButtonView)
	uberButtonView.addSubview(rideButton)

Kind regards.

Hello,

Anybody has a similar problem?

Hi @ivangarcialopez sorry to hear you're having trouble. In order for the button to show ride information, you need to have a valid access token or include your server token in your info.plist

Is your problem that that the ETA is not appearing or an issue with resizing the button that is cutting off the ETA information?

When investigating this error, are you seeing the .fetchCheapestProduct call succeed with a non-nil product ID?

I am seeing a similar issue. Code almost identical. I do see ETA and .fetchCheapestProduct does succeed with non-nil product ID but I never see a price...

And it just started working.

@javaboyjunior Did you find a solution to the problem of price not showing up? I am having that issue and can't seem to resolve it.

@seanperez29 are you including the server token in your app?

https://developer.uber.com/docs/riders/ride-requests/tutorials/button/ios#add-a-server-token

Closing since this is an old thread. I'll reopen if there's a reply! :)

I am getting the same issue as well in my iOS app. No estimation (whether time or price) showing up in my button

Are you including the server token as well?

I am. I had to 'fetchProducts' and then use one of the products productID values and attach it to RideParametersBuilder in order to get it to work. I understood from documentation that it should be optional:

Optional product_id from /v1/products endpoint (e.g. UberX). If not provided, most cost-efficient product will be used

Sorry for the bump but is this that the only solution to this issue now? I've noticed that fetchCheapestProduct() was removed from the SDK in a previous update so what would be the best way to display the prices now? I can't seem to get it to work. Should I be using fetchProducts like the previous commenter did? How can I get the needed product ID the easiest way?

The issue is kind of funny and I think uber should change there documentation. You need to fetch products and price estimates and then loadRideInformation(). Guess what! the default button width is smaller than required. detail answer..

uberClient.fetchProducts(pickupLocation: pickupLocation, completion: { (Products, _) in
            if (Products[0].productID != nil){
                uberClient.fetchPriceEstimates(pickupLocation: pickupLocation, dropoffLocation: dropoffLocation) { (priceEstimates, Response) in
                    SKActivityIndicator.dismiss()// used for loading animation, ignore if not not needed
                    builder.pickupLocation = pickupLocation
                    builder.pickupAddress = "pickup Address"
                    builder.pickupNickname = "pickup nick"
                    builder.dropoffLocation = dropoffLocation
                    builder.dropoffAddress = "drop Address"
                    builder.dropoffNickname = "drop nick"
                    builder.productID = Products[0].productID
                    uberReqButton.rideParameters = builder.build()
                    DispatchQueue.main.async {
                        uberReqButton.loadRideInformation()
                    }
                }
            }
        })