rides-ios-sdk icon indicating copy to clipboard operation
rides-ios-sdk copied to clipboard

Request Ride Button in iOS

Open ivangarcialopez opened this issue 8 years ago • 11 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.

ivangarcialopez avatar Dec 19 '16 17:12 ivangarcialopez

Hello,

Anybody has a similar problem?

ivangarcialopez avatar Jan 27 '17 17:01 ivangarcialopez

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?

jbrophy17 avatar Jan 31 '17 21:01 jbrophy17

lgtm

Hanjun

On Wed, Feb 1, 2017 at 5:22 AM, John Brophy [email protected] wrote:

Hi @ivangarcialopez https://github.com/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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/uber/rides-ios-sdk/issues/147#issuecomment-276496669, or mute the thread https://github.com/notifications/unsubscribe-auth/ACW3y36dpLqEvdUbDxkac-IYDJ9MYttKks5rX6YrgaJpZM4LQ-8g .

hanjunx avatar Feb 01 '17 01:02 hanjunx

i use android ;-p

On Jan 28, 2017 1:44 AM, "ivangarcialopez" [email protected] wrote:

Hello,

Anybody has a similar problem?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/uber/rides-ios-sdk/issues/147#issuecomment-275726599, or mute the thread https://github.com/notifications/unsubscribe-auth/ACW3y-ecL767zV_oYUbrzrxHxgcL4HfJks5rWizpgaJpZM4LQ-8g .

hanjunx avatar Feb 02 '17 23:02 hanjunx

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...

javaboyjunior avatar May 06 '17 21:05 javaboyjunior

And it just started working.

javaboyjunior avatar May 06 '17 21:05 javaboyjunior

@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 avatar May 12 '17 20:05 seanperez29

@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! :)

edjiang avatar Jul 10 '17 23:07 edjiang

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

mikesimonetta avatar Jun 20 '18 15:06 mikesimonetta

Are you including the server token as well?

edjiang avatar Jun 20 '18 19:06 edjiang

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

mikesimonetta avatar Jun 20 '18 19:06 mikesimonetta

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?

dan-burger avatar Oct 24 '18 15:10 dan-burger

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

ullash-ergo avatar Mar 25 '19 16:03 ullash-ergo