uber / uber-ios-sdk

Uber iOS SDK (beta)
https://developer.uber.com/docs
MIT License
376 stars 125 forks source link

Request Ride Button in iOS #147

Open ivangarcialopez opened 7 years ago

ivangarcialopez commented 7 years ago

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:

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 commented 7 years ago

Hello,

Anybody has a similar problem?

jbrophy17 commented 7 years ago

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?

hanjunx commented 7 years ago

lgtm

Hanjun

On Wed, Feb 1, 2017 at 5:22 AM, John Brophy notifications@github.com 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 commented 7 years ago

i use android ;-p

On Jan 28, 2017 1:44 AM, "ivangarcialopez" notifications@github.com 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 .

javaboyjunior commented 7 years ago

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 commented 7 years ago

And it just started working.

seanperez29 commented 7 years ago

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

edjiang commented 7 years ago

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

mikesimonetta commented 6 years ago

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

edjiang commented 6 years ago

Are you including the server token as well?

mikesimonetta commented 6 years ago

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

dan-burger commented 6 years ago

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?

ullash-ergo commented 5 years ago

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