Three lines

Uber

Developers

Migrating from the Widget

If you do not migrate your integration by May 31st, 2018 users will be automatically redirected to the new m.uber.com experience and will be required to sign in again.

In previous versions of the Uber Rides SDK there was a simple way to embed the Uber rider experience in your application with the Ride Request Widget. We have since announced we will no longer provide an embeddable solution in favor of providing a deep link to the latest Uber rider experience. In order to provide a consistent and seamless experience we are moving to the faster and more feature rich m.uber.com. m.uber.com is the ideal mobile web experience as it provides the latest new features like an interactive map, ability to manage payments/promotions, and improved performance. See the new m.uber.com in action:

m.uber.com.

In the past where you were embedding the Uber experience in your app you will now be linking to the native or mobile web app using a deep link. Depending on what is ideal for your use-case there are three types of deep links:

Use the Uber deep link generator to easily create a deep link that does not require a mobile SDK.

Find out more about how deep links can be used to leverage the Uber experience in the deep links guide.

In this tutorial we will walk through three ways to leverage deep links to replace the Ride Request Widget experience:

  • Option 1: Use a m.uber.com deep link to open with the default browser
  • Option 2: Deep link via the Ride Request Button
  • Option 3: Build a deep link using the SDK

The iOS and Android SDKs provide the Ride Request Button that makes it easy to link to the Uber rider experience by preselecting a product and setting the ride parameters like pickup and destination. The ideal migration path is to use universal links and the sdk deep link generator to launch the Uber rider experience. By default, if the Uber app is installed it will be opened, if not the app store will be opened. If you prefer you can change the fallback type so that if the Uber app is not installed the behavior will be to not open the app store, but instead load the m.uber.com app with the ride parameters prefilled. If you would prefer to embed this solution you can use the generated deep link with a webview or chrometab to provide a more seamless experience.

Just like our native mobile app our mobile web app enables you to link seamlessly between the mobile web experiences. The link format is the same as universal links without the /ul/ prefix. If you use the direct m.uber.com link the app will always open in the default web browser and not attempt to load the native mobile app if installed. In the examples above you can set the fallback strategy for deep links to either open the app store by default or open the system browser with an m.uber.com deeplink.

In the examples above you can set the fallback strategy for deep links to either open the app store by default or open the system browser with an m.uber.com deeplink. If you prefer to open the system browser in an embedded web view which will most closely mimic the Ride Request Widget experience you will need to remove the /ul/ prefix from the deep link and use an embedded web view.

Find out more in the deep links guide.

iOS

The iOS 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 = "UberHQ"
builder.dropoffAddress = "1455 Market Street, San Francisco, California"
let rideParameters = builder.build()

let requestingBehavior = DeeplinkRequestingBehavior(fallbackType: .mobileWeb)
let button = RideRequestButton(rideParameters: rideParameters, requestingBehavior: requestingBehavior)
// 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:@"1455 Market Street, San Francisco, California"];
[builder setDropoffNickname:@"UberHQ"];
UBSDKRideParameters *rideParameters = [builder build];

UBSDKDeeplinkRequestingBehavior *requestingBehavior = [[UBSDKDeeplinkRequestingBehavior alloc] initWithFallbackType:UBSDKDeeplinkFallbackTypeMobileWeb];

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

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

Find out more in the button guide or in the iOS SDK readme.

Android

The RideRequestButton offers the quickest way to integrate Uber into your application. You can add a Ride Request Button to your View like you would any other View:

RideRequestButton requestButton = new RideRequestButton(context);
requestButton.setDeeplinkFallback(Deeplink.Fallback.MOBILE_WEB);
layout.addView(requestButton);

This will create a request button with deeplinking 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.

You can also add your button through XML:

<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:uber="http://schemas.android.com/apk/res-auto"
   android:layout_width="match_parent"
   android:layout_height="match_parent">

   <com.uber.sdk.android.rides.RideRequestButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      uber:ub__style="black"/>
</LinearLayout>

With all the necessary parameters set, pressing the button will seamlessly prompt a ride request confirmation screen.

Find out more in the button guide or in the Android SDK readme.

If you don’t want to use the Uber-provided button, you can also manually initiate a deep link in a similar fashion as above. The Ride Request Deeplink provides an easy to use method to provide ride functionality against the installed Uber app or the mobile web experience.

Without any extra configuration, the RideRequestDeeplink will deep link to the Uber app. 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. By default if the Uber app is installed the deep link will open the native app, but the fallback strategy can be configured using the deep link builder to go to the app store or m.uber.com experience.

iOS
// Swift
import UberRides
import CoreLocation

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

let deeplink = RequestDeeplink(rideParameters: rideParameters, fallbackType: .mobileWeb)
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];

Find out more in the deep links guide or in the iOS SDK readme.

Android

SessionConfiguration config = new SessionConfiguration.Builder()
    .setClientId("<CLIENT_ID>")
    .setClientSecret("<CLIENT_SECRET>")
    .setServerToken("<SERVER_TOKEN>")
    .build();

RideParameters rideParams = new RideParameters.Builder()
  .setProductId("a1111c8c-c720-46c3-8534-2fcdd730040d")
  .setPickupLocation(37.775304, -122.417522, "Uber HQ", "1455 Market Street, San Francisco, California")
  .setDropoffLocation(37.795079, -122.4397805, "Embarcadero", "One Embarcadero Center, San Francisco")
  .build();

RideRequestDeeplink deeplink = new RideRequestDeeplink.Builder(context)
                        .setSessionConfiguration(config)
                        .setRideParameters(rideParams)
                        .build();

deeplink.execute();

After configuring the Ride Parameters, pass them into the RideRequestDeeplink builder object to construct and execute the deeplink. The Ride Request Deeplink will prefer to use deferred deeplinking by default, where the user is taken to the Play Store to download the app, and then continue the deep link behavior in the app after installation. However, an alternate fallback may be used to prefer the mobile web experience instead.

To prefer mobile web over an app installation, set the fallback on the builder:


SessionConfiguration config = new SessionConfiguration.Builder()
    .setClientId("<CLIENT_ID>")
    .setClientSecret("<CLIENT_SECRET>")
    .setServerToken("<SERVER_TOKEN>")
    .build();

RideRequestDeeplink deeplink = new RideRequestDeeplink.Builder(context)
                        .setSessionConfiguration(config)
                        .setFallback(Deeplink.Fallback.MOBILE_WEB)
                        .setRideParameters(rideParams)
                        .build();

// to launch as a custom tab with browser fallback
deeplink.execute();

// to get the mobile deep link as a string
String uri = deeplink.getUri();

Find out more in the deep links guide or in the Android SDK readme.

Uber

Developers
© 2023 Uber Technologies Inc.