Uber now has an official ride request widget. You should probably use it instead of this.
This repository is no longer being maintained.
Summon Uber from your iOS app with 2 lines of code.
#import <GPUberViewController.h>
// ...
GPUberViewController *uber = [[GPUberViewController alloc] initWithServerToken:@"your_server_token"];
// optional
uber.startLocation = CLLocationCoordinate2DMake(40.7471787,-73.997494);
uber.endLocation = CLLocationCoordinate2DMake(40.712774,-74.006059);
[uber showInViewController:self];
- Go to the GPUberViewDemo directory.
- Open the
.xcworkspace
(not the.xcodeproj
) file. - Run the app in the Simulator or on the device.
If the phone has the Uber app installed, tapping any of the Uber service buttons will bring it up with the appropriate parameters already set. Otherwise the Uber mobile website will be launched.
platform :ios, '7.1'
pod "GPUberView"
To use this library you need a valid Server Token from Uber. You can get it here: https://developer.uber.com
For iOS 9 compatibility, add the following scheme to your application's info.plist
:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>uber</string>
</array>
#import <GPUberViewController.h>
Pass in your Uber server token for authentication.
GPUberViewController *uber = [[GPUberViewController alloc] initWithServerToken:@"your_server_token"];
You can pass-in the desired pickup and dropoff coordinates as CLLocationCoordinate2D structs.
// example: from Boston South Station to Fenway Park
uber.startLocation = CLLocationCoordinate2DMake(40.7471787,-73.997494);
uber.endLocation = CLLocationCoordinate2DMake(40.712774,-74.006059);
-
If you omit
startLocation
, GPUberView will attempt to determine it based on your user's current location. For iOS 8.0 and higher, this requires you to add theNSLocationWhenInUseUsageDescription
key into your application'sInfo.plist
file. The value should be a short string explaining the reason why your app needs location (e.g., "Uber needs to determine your pickup location."). -
If you omit the
endLocation
, GPUberView will not be able to calculate the price estimate, but still will be able to show the estimated pickup time.
Note: If you supply both the pickup and dropoff locations, make sure the distance between the two isn't exceedingly large. Most Uber products cannot drive you from San Francisco to New York.
You can also pass in user-readable names of the pickup and dropoff points. These labels will be shown to the user as the pickup and dropoff labels in the Uber app once launched. If not supplied, GPUberView (or the Uber app itself) will attempt to determine these automatically.
uber.startName = @"South Station";
uber.endName = @"Fenway Park";
Add your Uber client id to receive Uber credits for new user signups. You can get it here: https://developer.uber.com
uber.clientId = @"your_client_id";
[uber showInViewController:self];
GPUberView is available under the MIT license. See the LICENSE file for more info.