Code Monkey home page Code Monkey logo

rides-ios-sdk's Introduction

Uber Rides iOS SDK

This Swift library allows you to integrate the Uber Rides API into your iOS app.

Requirements

  • iOS 11.0+
  • Xcode 10.0+
  • Swift 4.2+

Installing the Uber Rides SDK

To install the Uber Rides SDK, you may use CocoaPods, Carthage, or add it to your project manually

pod 'UberRides', '~> 0.14'

Carthage

github "uber/rides-ios-sdk" ~> 0.14

Getting Started

SDK Configuration

To begin making calls to the Uber API, you need to register an application on the Uber Developer Site and get credentials for your app.

Then, configure your Xcode with information for the Uber SDK. Locate the Info.plist file for your application. Right-click this file and select Open As > Source Code

Add the following code snippet, replacing the placeholders within the square brackets ([]) with your app’s information from the developer dashboard. (Note: Do not include the square brackets)

<key>UberClientID</key>
<string>[ClientID]</string>
<key>UberServerToken</key>
<string>[Server Token]</string>
<key>UberDisplayName</key>
<string>[App Name]</string>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>uber</string>
    <string>uberauth</string>
</array>

Note: Your Server Token is used to make Price & Time estimates when your user hasn't authenticated with Uber yet. We suggest adding it in your Info.plist only if you need to get estimates before your user logs in.

Ride Request Button

The RideRequestButton is a simple way to show price and time estimates for Uber products and can be customized to perform various actions. The button takes in RideParameters that can describe product ID, pickup location, and dropoff location. By default, the button shows no information.

To display a time estimate, set the product ID and pickup location. To display a price estimate, you need to additionally set a dropoff location.

Request Buttons Screenshot

Import the library into your project, and add a Ride Request Button to your view like you would any other UIView:

// Swift
import UberRides

let button = RideRequestButton()
view.addSubview(button)
// Objective-C
@import UberRides;

UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] init];
[view addSubview:button];

This will create a request button with default behavior, with the pickup pin set to the user’s current location. The user will need to select a product and input additional information when they are switched over to the Uber application.

Adding Parameters with RideParameters

The SDK provides an simple object for defining your ride requests. The RideParameters object lets you specify pickup location, dropoff location, product ID, and more. Creating RideParameters is easy using the RideParametersBuilder object.

// Swift
import UberRides
import CoreLocation

let builder = RideParametersBuilder()
let pickupLocation = CLLocation(latitude: 37.787654, longitude: -122.402760)
let dropoffLocation = CLLocation(latitude: 37.775200, longitude: -122.417587)
builder.pickupLocation = pickupLocation
builder.dropoffLocation = dropoffLocation
builder.dropoffNickname = "Somewhere"
builder.dropoffAddress = "123 Fake St."
let rideParameters = builder.build()

let button = RideRequestButton(rideParameters: rideParameters)
// Objective-C
@import UberRides;
@import CoreLocation;

UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude:37.787654 longitude:-122.402760];
CLLocation *dropoffLocation = [[CLLocation alloc] initWithLatitude:37.775200 longitude:-122.417587];
[builder setPickupLocation:pickupLocation];
[builder setDropoffLocation:dropoffLocation];
[builder setDropoffAddress:@"123 Fake St."];
[builder setDropoffNickname:@"Somewhere"];
UBSDKRideParameters *rideParameters = [builder build];

UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] initWithRideParameters:rideParameters];

We suggest passing additional parameters to make the Uber experience even more seamless for your users. For example, dropoff location parameters can be used to automatically pass the user’s destination information over to the driver. With all the necessary parameters set, pressing the button will seamlessly prompt a ride request confirmation screen.

Note: If you are using a RideRequestButton that deeplinks into the Uber app and you want to specify a dropoff location, you must provide a nickname or formatted address for that location. Otherwise, the pin will not display.

You can also use the RideRequestButtonDelegate to be informed of success and failure events during a button refresh.

Ride Request Deeplink

If you don't want to use the Uber-provided button, you can also manually initiate a deeplink in a similar fashion as above:

// Swift
import UberRides
import CoreLocation

let builder = RideParametersBuilder()
// ...
let rideParameters = builder.build()

let deeplink = RequestDeeplink(rideParameters: rideParameters)
deeplink.execute()
// Objective-C
@import UberRides;
@import CoreLocation;

UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
// ...
UBSDKRideParameters *rideParameters = [builder build];

UBSDKRequestDeeplink *deeplink = [[UBSDKRequestDeeplink alloc] initWithRideParameters:rideParameters];
[deeplink executeWithCompletion:nil];

With the Ride Request deeplink, you can specify a fallback for users that don't have the Uber app installed. With a fallback, they'll get redirected to either the mobile web version of Uber, or the App Store. To do so, simply add the fallbackType parameter:

// Swift
let deeplink = RequestDeeplink(rideParameters: rideParameters, fallbackType: .mobileWeb) // Or .appStore

// Objective-C
UBSDKRequestDeeplink *requestDeeplink = [[UBSDKRequestDeeplink alloc] initWithRideParameters:rideParameters 
                                          fallbackType:UBSDKDeeplinkFallbackTypeMobileWeb];

Login with Uber

To use any of the SDK's other features, you need to have the end user authorize your application to use the Uber API.

Setup

First, open up the Uber Developer Dashboard. Go to the Authorizations tab and under App Signatures, put in your iOS application's Bundle ID.

We also need to register a Redirect URL for your application. This ensures that Uber sends users to the correct application after they log in. Make a URL in this format, and save your application: YourApplicationBundleID://oauth/consumer.

In your Xcode project, you need to register your URL scheme as well as the callback URL with the Uber SDK. Copy this into your Info.plist, replacing the relevant values:

Note: If one of the following keys already exists in your Info.plist file, you will have to add the values to them and not duplicate the keys.

<key>UberCallbackURIs</key>
<array>
    <dict>
        <key>UberCallbackURIType</key>
        <string>General</string>
        <key>URIString</key>
        <string>[Your Bundle ID Here]://oauth/consumer</string>
    </dict>
</array>
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>[Your Bundle ID Here]</string>
        </array>
    </dict>
</array>

You also need to modify your application's App Delegate to make calls to the RidesAppDelegate to handle URLs.

// Swift
// Add the following calls to your AppDelegate
import UberCore
    
@available(iOS 9, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    let handledUberURL = UberAppDelegate.shared.application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation] as Any)

    return handledUberURL
}
    
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    let handledUberURL = UberAppDelegate.shared.application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)

    return handledUberURL
}
// Objective-C
// Add the following calls to your AppDelegate
@import UberCore;

// iOS 9+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
    BOOL handledURL = [[UBSDKAppDelegate shared] application:app open:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
    
    return handledURL;
}

// iOS 8
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    BOOL handledURL = [[UBSDKAppDelegate shared] application:application open:url sourceApplication:sourceApplication annotation:annotation];
    
    return handledURL;
}

Login Button

The LoginButton is a simple way to authorize your users. You initialize the button requesting certain scopes, or permissions from Uber. More about scopes. When the user taps the button, the login will be executed.

You can optionally set a LoginButtonDelegate to receive notifications for login/logout success.

// Swift
import UberCore

let scopes: [UberScope] = [.profile, .places, .request]
let loginManager = LoginManager(loginType: .native)
let loginButton = LoginButton(frame: CGRect.zero, scopes: scopes, loginManager: loginManager)
loginButton.presentingViewController = self
loginButton.delegate = self
view.addSubview(loginButton)

// Mark: LoginButtonDelegate
    
func loginButton(_ button: LoginButton, didLogoutWithSuccess success: Bool) {
	// success is true if logout succeeded, false otherwise
}
    
func loginButton(_ button: LoginButton, didCompleteLoginWithToken accessToken: AccessToken?, error: NSError?) {
    if let _ = accessToken {
        // AccessToken Saved
    } else if let error = error {
        // An error occured
    }
}
// Objective-C
@import UberCore;

NSArray<UBSDKScope *> *scopes = @[UBSDKScope.profile, UBSDKScope.places, UBSDKScope.request];

UBSDKLoginManager *loginManager = [[UBSDKLoginManager alloc] initWithLoginType:UBSDKLoginTypeNative];

UBSDKLoginButton *loginButton = [[UBSDKLoginButton alloc] initWithFrame:CGRectZero scopes:scopes loginManager:loginManager];
loginButton.presentingViewController = self;
[loginButton sizeToFit];
loginButton.delegate = self;
[self.view addSubview:loginButton];

#pragma mark - UBSDKLoginButtonDelegate

- (void)loginButton:(UBSDKLoginButton *)button didLogoutWithSuccess:(BOOL)success {
	// success is true if logout succeeded, false otherwise
}

- (void)loginButton:(UBSDKLoginButton *)button didCompleteLoginWithToken:(UBSDKAccessToken *)accessToken error:(NSError *)error {
    if (accessToken) {
		// UBSDKAccessToken saved
    } else if (error) {
		// An error occured
    }
}

Custom Integration

If you want to provide a more custom experience in your app, there are a few classes to familiarize yourself with. Read the sections below and you’ll be requesting rides in no time!

Uber Rides API Endpoints

The SDK exposes all the endpoints available in the Uber Developers documentation. Some endpoints can be authenticated with a server token, but for most endpoints, you will require a bearer token. A bearer token can be retrieved via implicit grant, authorization code grant, or SSO. To authorize privileged scopes, you must use authorization code grant or SSO.

Read the full API documentation at CocoaDocs

The RidesClient is your source to access all the endpoints available in the Uber Rides API. With just your server token, you can get a list of Uber products as well as price and time estimates.

// Swift example
let ridesClient = RidesClient()
let pickupLocation = CLLocation(latitude: 37.787654, longitude: -122.402760)
ridesClient.fetchProducts(pickupLocation: pickupLocation, completion:{ products, response in
    if let error = response.error {
        // Handle error
        return
    }
    for product in products {
        // Use product
    }
})
// Objective-C example
UBSDKRidesClient *ridesClient = [[UBSDKRidesClient alloc] init];
CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude: 37.787654 longitude: -122.402760];
[ridesClient fetchProductsWithPickupLocation: pickupLocation completion:^(NSArray<UBSDKProduct *> * _Nullable products, UBSDKResponse *response) {
    if (response.error) {
        // Handle error
        return;
    }
    for (UBSDKProduct *product in products) {
        // Use product
    }
}];

Native / SSO Authorization

To get access to more informative endpoints, you need to have the end user authorize your application to access their Uber data.

The easiest form of authorization is using the .native login type. It allows you to request Privileged scopes and, if your user is logged into the Uber app, it doesn't require your user to enter a username and password. It requires the user to have the native Uber application on their device.

Native authentication can occur either through the main Uber rides app or through the Uber Eats app. You can also fallback from one app to another, so that for example if the user does not have the UberEats app installed on their device, you can instead authenticate through the main Uber rides app:

// Swift
let loginManager = LoginManager(loginType: .native, productFlowPriority: [UberAuthenticationProductFlow(.eats), UberAuthenticationProductFlow(.rides)])
// Objective-C
UBSDKUberAuthenticationProductFlow *eatsProduct = [[UBSDKUberAuthenticationProductFlow alloc] init:UberProductTypeEats];
UBSDKUberAuthenticationProductFlow *ridesProduct = [[UBSDKUberAuthenticationProductFlow alloc] init:UberProductTypeRides];
UBSDKLoginManager *loginManager = [[UBSDKLoginManager alloc] initWithLoginType:loginType productFlowPriority:@[ eatsProduct, ridesProduct ]];

The LoginManager defaults to using the Native login type using the main Uber rides app, so you can simply instantiate a LoginManager and call login() with your requested scopes.

// Swift
let loginManager = LoginManager()
loginManager.login(requestedScopes:[.request], presentingViewController: self, completion: { accessToken, error in
    // Completion block. If accessToken is non-nil, you’re good to go
    // Otherwise, error.code corresponds to the RidesAuthenticationErrorType that occured
})
// Objective-C
UBSDKLoginManager *loginManager = [[UBSDKLoginManager alloc] init];
[loginManager loginWithRequestedScopes:@[ UBSDKScope.request ] presentingViewController: self completion: ^(UBSDKAccessToken * _Nullable accessToken, NSError * _Nullable error) {
    // Completion block. If accessToken is non-nil, you're good to go
    // Otherwise, error.code corresponds to the RidesAuthenticationErrorType that occured
}];

Note: The presentingViewController parameter is optional, but if provided, will attempt to intelligently fallback to another login method. Otherwise, it will redirect the user to the App store to download the Uber app.

Auth Method Token Type Allowed Scopes
None Server None (can access products and estimates)
Implicit Grant Bearer General
Authorization Code Grant Bearer Privileged and General
SSO Bearer Privileged and General

Custom Authorization / TokenManager

If your app allows users to authorize via your own customized logic, you will need to create an AccessToken manually and save it in the keychain using the TokenManager.

// Swift
let accessTokenString = "access_token_string"
let token = AccessToken(tokenString: accessTokenString)
if TokenManager.save(accessToken: token) {
    // Success
} else {
    // Unable to save
}
// Objective-C
NSString *accessTokenString = @"access_token_string";
UBSDKAccessToken *token = [[UBSDKAccessToken alloc] initWithTokenString: accessTokenString];
if ([UBSDKTokenManager saveWithAccessToken: token]) {
	// Success
} else {
	// Unable to save
}

The TokenManager can also be used to fetch and delete AccessTokens

// Swift
TokenManger.fetchToken()
TokenManager.deleteToken()
// Objective-C
[UBSDKTokenManager fetchToken];
[UBSDKTokenManager deleteToken];

Prefilling User Information

If you would like text fields during signup to be pre-populated with user information you can do so using the prefill API. Partial information is accepted. There are two ways to provide this information:

Using the LoginButton / DataSource

// Conform to the LoginButtonDataSource
class MyClass: NSObject, LoginButtonDataSource { 

    // Implement the the delegate method to provide prefill values
    
    func prefillValues(_ button: LoginButton) -> Prefill? {
        Prefill(
            email: "[email protected]",
            phoneNumber: "12345678900",
            firstName: "Jane",
            lastName: "Doe"
        )
    }
}

Using LoginManager Directly

let loginManager = LoginManager(loginType: .authorizationCode)

let prefill = Prefill(
    email: "[email protected]",
    phoneNumber: "12345678900",
    firstName: "Jane",
    lastName: "Doe"
)

loginManager.login(
    scopes: [.profile],
    presentingViewController: viewController,
    prefillValues: prefill,
    completion: nil
)

Getting help

Uber developers actively monitor the Uber Tag on StackOverflow. If you need help installing or using the library, you can ask a question there. Make sure to tag your question with uber-api and ios!

For full documentation about our API, visit our Developer Site.

Contributing

We ❤️ contributions. Found a bug or looking for a new feature? Open an issue and we'll respond as fast as we can. Or, better yet, implement it yourself and open a pull request! We ask that you include tests to show the bug was fixed or the feature works as expected.

Note: All contributors also need to fill out the Uber Contributor License Agreement before we can merge in any of your changes.

Please open any pull requests against the develop branch.

License

The Uber Rides iOS SDK is released under the MIT license. See the LICENSE file for more details.

rides-ios-sdk's People

Contributors

chardane avatar christinekim avatar dev-nexonia avatar ebgraham avatar edjiang avatar evisoup avatar faarwa avatar gloffreda avatar jacobbendicksen avatar jameseunson avatar jasongithub avatar jbrophy17 avatar lashkhi avatar lesyk avatar lhasiuk avatar lianqiao avatar mohssenfathi avatar piotr-sekara avatar rmuhamedgaliev avatar samwize avatar shampab avatar suriksarkisyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rides-ios-sdk's Issues

Layout Error

I am making Proof of Concept. In POC, I am using Uber SDK. I am simply following the steps for integration mentioned under the document. I am getting layout Errors for constraints. For the reference, I have attached the screenshot of the console window. I checked "Debug View Hierarchy" option, the UberLogin Button is there but It always remains out of the frame area of View.

I am using IDE : Xcode 7.3.1, Deployment Target : iOS 9.3, Development Language : Swift
layout errors

Error: access token failed to save to keychain

Hello!

Quick question, the first time I login it gets stuck at login screen printing this error:
Error: access token failed to save to keychain

traced it and here is the part of the code failing:

if !TokenManager.saveToken(accessToken, tokenIdentifier: accessTokenIdentifier, accessGroup: keychainAccessGroup) {
            print("Error: access token failed to save to keychain")
        }

however if I close the app and open again, works great.
Am I missing something?

Developer accounts unable to request non-whitelisted privileged scopes via SSO

Expected: A developer can request any scopes for their own application, even if it hasn't been approved yet

Actual: A developer requesting a privileged scope, via SSO, that hasn't been enabled will get an invalid_scope error.

Steps to Reproduce:

  1. Request a privileged scope (request, all_trips, request_receipt) that is disabled on your app's dashboard via SSO.
  2. Tap the "Allow" button on the scope accept screen.
  3. Get redirected to your app with the invalid_scope error

Requests to Estimates Endpoints should prioritize Server Token over Bearer Token

Hey there guys.

Over two weeks ago I was able to implement the logic of the Rides Client fetching up some uber price estimates properly with the UberServerToken.
Today I started testing my app again and suddendly I'm always receiving "unauthorized" in my fetchPriceEstimatesWithPickupLocation block completionHandler...
I triple checked my UberServerToken in my plist, tried adding another one imagining it was this token problem. I even made a call to the Uber API "GET /v1/estimates/price" which does the same thing as the method fetchPriceEstimatesWithPickupLocation with the same Server Token and the REST API is answering me properly, with "200 OK" and my price estimates...

Am I missing something?

Xcode 6.3

Hi

The SDK says it require Xcode 7.0. Why it is that ?
Will it work with Xcode 6.3 ?

Thanks

The provided app signature did not match what was expected

Hi there,

When I'm trying to use Uber SSO authorization, I get an error "The provided app signature did not match what was expected" and I don't know why. What means "app signature" in this context? Is it related to the environment I'm running my code (currently working on React Native Rides SDK port)? Where can I find some info about this issue?

UPD: I don't know what has been changed, but after I created a new project and repeated all the steps one more time, I started to get a different error: "User cancelled the login process". Would be nice if you can refer me to resource with information about these error messages.

Thanks in advance! ❤️

Add Travis-CI / Fix travis.yml

Tests pass locally but are failing on Travis-CI. Possibly an issue around using the iOS keychain, needs more investigation

SSO fails for correctly configured China apps

Correctly configured China based apps are unable to login via SSO. The Uber app will returns an invalid_client_id error even when the client ID is correct.

Root cause is an incorrect value being sent for login_type. A fix will be available shortly.

Loading feedback aside the error handling

Hi, I am using the RideRequestViewController and have realised sometimes, its takes a little bit before the view fully load. Is there other API calls to check for loading progress? I want to be able to show an ActivityIndicator while the view this loading so users don't think the app is frozen. Anyway to do that? Thanks

Uber DeepLink Button Trigger

I have integrated an Uber button request with deeplink , when the button is pressed there is a selected state color, is there a way to change the selected state color to clear color , is there a way to get a call back such that the deeplink is triggered

New Uber Logo

Will there be an update soon to incorporate the new Uber logo?

Add Swift 3 / Xcode 8 support

When I add github "https://github.com/uber/rides-ios-sdk" ~> 0.5 , and do a carthage update, I get the following error:

The following build commands failed:
    Check dependencies
(1 failure)
A shell task (/usr/bin/xcrun xcodebuild -workspace /Users/Carthage/Checkouts/ObjectMapper/ObjectMapper.xcworkspace -scheme ObjectMapper-iOS -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** CLEAN FAILED **


The following build commands failed:
    Check dependencies
(1 failure)
** BUILD FAILED **

Using Xcode 8 Beta 3 , macOS El Capitan 10.11.6.

UBSDKLoginManager shows error

I tried to login with that code which is give below - with or without using redirect_URI but it always show error orderly
1.The Redirect URI provided did not match what was expected.
2. Invalid Redirect URI provided. or The server was unable to understand your request. most of time its crashes.
even I tried the example code It shows same error. I checked my whole project but there is no any other issue I found. Please help me to solve my issue.
Thanks

UBSDKLoginManager *loginManager = [[UBSDKLoginManager alloc]init];
NSArray<UBSDKRidesScope *> *requestedScopes = @[ UBSDKRidesScope.RideWidgets, UBSDKRidesScope.Profile, UBSDKRidesScope.Places ];
[loginManager loginWithRequestedScopes:requestedScopes presentingViewController:self completion:^(UBSDKAccessToken * _Nullable accessToken, NSError * _Nullable error) {
    if (accessToken) {
        //[self _showMessage:UBSDKLOC(@"Saved access token!")];
    } else {
        //[self _showMessage:error.localizedDescription];
    }
}];

Could not access property contentHeight

I was wondering why i could not access variable "contentHeight", the variable is public only.

public class RequestButton: UIButton {
    var deeplink: RequestDeeplink?
    var contentWidth: CGFloat = 0
    var contentHeight: CGFloat = 0

See the variable is there, and when i try to access it, it does not even show up in RequestButton instance variable.

let uberButton = RequestButton()
uberButton.contentHeight  // The contentHeight is not showing here.

Compiler Error

Hi,

My app was running successfully until i did a pod update. After pod update I tried clean build, close Xcode and open and build, etc but nothing worked. Its giving me 'Use of undeclared type 'RequestButton' ' and 'Type RidesClient has no member sharedInstance' (In line RidesClient.sharedInstance.configureClientID("")). Please help.

Thanks,

Latitude/Longitude parameter type

Would be more appropriate if the setPickupLocationWithLatitude: longitude: nickname: address: method would use CLLocationDegrees as type for longitude and latitude instead of NSString.

Documentation unclear about Server Token in info.plist

Hello as it documented in the the section

All the button needs to gather this additional information is your server token to be configured in the Info.plist as described in the SDK Configuration section. To display a time estimate, set the product ID and pickup location. To display a price estimate, you need to additionally set a dropoff location

So when I go back to SDK Configuration section i am unable to find the information for which server token key is going to be used in the app info.plist. am i missing something ?
Attaching screenshot please confirm Server token key

screen shot 2016-07-04 at 1 24 56 pm

Setting Product ID for RideRequesting behavior

Hello! I want to know if this is a bug. When I set the product id for let's say a Deep Link Behavior. I get the correct product on the Uber app. But when I switch to UBSDKRideRequestViewRequestingBehavior. The product does not seem to be highlighted. Did I miss something the implementation? Thanks!

UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
[builder setProductID:myRideData[@"productID"]];

CLLocation *pickupLocation = [[CLLocation alloc] initWithLatitude:[originCoordsLat doubleValue] longitude:[originCoordsLng doubleValue]];
[builder setPickupLocation:pickupLocation nickname:originAddress];

CLLocation *dropoffLocation = [[CLLocation alloc] initWithLatitude:[destinationCoordsLat doubleValue] longitude:[destinationCoordsLng doubleValue]];
[builder setDropoffLocation:dropoffLocation nickname:destinationAddress];
// You can chain builder function calls

UBSDKRideParameters *rideParameters = [builder build];

University of Miami button

I am on the student government at the University of Miami, and would like to learn more about contracting with Uber. We would like to contract a program similar to the University of Southern California's. Please email me at [email protected]

How to change the text color on Ride button?

Hi, I need to know how to change the text color on Ride button of our choice other than default styles and also the alignment of the text.
Will appreciate your help.

Thanks
Adeel

pickupLocation is ignored when opening the uber app

When I set the pickup location and click the button, it opens the Uber app ok, and immediately changes the pickup location from the one specified in the button to my current location.

This is all the code I have in the main ViewController (in a minimal app that has only this):

import UIKit
import UberRides

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let button = RequestButton()
        button.setProductID("6ad061f8-9a50-4dcc-b12a-d810a0262d31")
        button.setPickupLocation(
            latitude: "-34.912342",
            longitude: "-56.178625",
            address: "Gonzalo Ramirez 1676",
            nickname: "Sinergia Cowork"
        )

        view.addSubview(button)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

}

I've tried with and without setting the product ID, with and without the address field, and with and without the nickname field. The result is that it always sets my request to my current location, instead of the desired location.


  • SDK installed from master via Carthage.
  • XCode 7.2 (7C68)
  • iOS 9.2 (13C75)
  • Uber v2.110.0

Uber opens Safari when i click on uberButton

I have not installed uber in my iPhone, so uber is opening a URL in Safari. It is okay, Safari says could not load URL. Why ??

Really i don't wanna open Safari if it is not opening a proper page. I don't wanna create a bad user experience.

Would you give a chance for developers to decide choose way to open the URL ? via Uber app or via Safari.

Carthage Compatible!

Please make this Carthage Compatible. It'd be a whole lot easier to integrate with a project. Thanks!

ClientLoginError UberSDK

I have followed the exact implementation of Uber iOS SDK in my iOS, and made sure that Callback URI schemes are registered in the uber developer dashboard which i have used in the app. But its throwing UBSDKRidesClientError. Here is my code for the button:

UBSDKRideRequestButton *button = [[UBSDKRideRequestButton alloc] init];
UBSDKRidesClient *ridesClient = [[UBSDKRidesClient alloc] init];

__block UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
builder = [builder setPickupLocation: pickupLocation];
builder = [builder setDropoffLocation: dropoffLocation];
[ridesClient fetchCheapestProductWithPickupLocation: pickupLocation completion:^(UBSDKUberProduct* _Nullable product, UBSDKResponse* _Nullable response) {

    if (product) {
        builder = [builder setProductID: product.productID];
        button.rideParameters = [builder build];
        [button loadRideInformation];
    }
}];

Will appreciate any help

Nickname required for drop-off?

I couldn't seem to get the drop off location to pre-fill unless I used added a nickname, is this intentional?

[_requestButton setPickupLocationWithLatitude:pickupLat longitude:pickupLong nickname:nil address:nil];

Refresh Endpoint Returns Error

The Refresh endpoint is not correctly refreshing tokens when given a valid refresh token. Data is being submitted in the incorrect form

UBSDKRidesAppDelegate not found

Hello Guys, when i copy and paste this method in my appdelegate , I get an error that UBSDKRidesAppDelegate not found. Please help

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
    BOOL handledURL = [[UBSDKRidesAppDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];

    if (!handledURL) {
        // Other URL logic
    }

    return true;
}

Drop-off location not set

Originally we were using uber://?action=setPickup&pickup=my_location&dropoff[latitude]=%f&dropoff[longitude]=%f&dropoff[nickname]=%@ for launching Uber app with drop-off location already set. It works fine with deep-linking, but with the SDK, the nickname or address is pre-filled, but the drop-off pin is missing.

setProductID

hi ,i want know UBSDKRideParametersBuilder *builder = [[UBSDKRideParametersBuilder alloc] init];
[builder setProductID:@"a1111c8c-c720-46c3-8534-2fcdd730040d"];

setProductID:@"a1111c8c-c720-46c3-8534-2fcdd730040d" what this is ,, how get it

Providing Custom Logic for LoginButton

I would like to be able to handle the OAuth on my own if the user does not have the Uber app installed. I have been able to achieve this with using the LoginManager directly with my own button.

Here's is my logic for handling it:

    let loginManager = LoginManager()
    loginManager.login(requestedScopes:[RidesScope.Request, RidesScope.AllTrips, RidesScope.Places], presentingViewController: self, completion: { accessToken, error in
        print("Token: \( accessToken?.tokenString)")
        print(error)
        if error != nil {
            uber.scopes = ["request", "all_trips", "places"]
            uber.authorize { (result) in
                switch result {
                case .Success(let token) :
                    print("Token: \(accessToken)")
                    self.token = accessToken
                    //handle successful login
                    break
                case .Failure(let error) :
                    print(error)
                    //handle failed login
                    break
                }
            }
        }
    })

A couple notes:

  1. I have yet to get the login manager to login successfully. It says that my app is not authorized for the requested scopes but when it falls back on my own OAuth, with the same scopes, it works.
  2. How do I make the SDK aware of the login after I handle it myself?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.