Using Salesforce geo fields with the Uber Rides SDK for custom iOS apps

In between meetings and other activities I’ve been building out a pretty comprehensive sample iOS using Salesforce as the backend. I wanted to leverage the use case and provide a reference app that covers all the typical patterns when connecting to Salesforce. Now that I have these covered, I wanted to look at the mobile app experience and how a user might want the app to improve a task — in my case, how to tour a home for sale.

In my experience, there are two things about buying a house that help me decide whether I even want to meet a broker and get a personal tour. The first thing is a tour. Unfortunately, like many of us, our time is pretty precious. Because of this, I already added in the ability to use a live agent snap-in via the Salesforce Service Cloud to allow a potential home owner to take a virtual tour.

Using Live Agent to check out a property

Let’s assume you liked the virtual tour and the agent was helpful, now you want go tour the house. I live in San Francisco. If I want to tour a house I need to factor in the hassle of parking just to check the house out. And this assumes you even have a car, which is not always the case in a big city. Thankfully, ride share companies like Uber solve this problem. And even better, for a mobile developer, Uber offers a Ride Request SDK.

The Salesforce App Cloud supports geolocation fields. For my sample app, I have a property entity modelled using the visual Schema Builder that includes a geo field called location. Geo-location fields are a composite of longitude and latitude co-ordinates and can be retrieved by your native mobile app using the Mobile SDK:

 let soqlGetAllProperties = String(“select Id, Location__c, Name, OwnerId, Picture__c, Price__c from Property__c”)
Geo-location fields in Salesforce Schema Builder

Within Swift, I can take these values and create a CLLocation variable:

var propertyLocation : CLLocation?
propertyLocation = CLLocation(latitude:!.latitude!, longitude:!.longitude!)

Now that I have my CLLocation, I can quick use the Uber Ride Request widget to pass the details in as my drop-off location:

private func buildRideRequestWidgetButton(loginType: LoginType) -> RideRequestButton {
   let loginManager = LoginManager(loginType: loginType)
   let requestBehavior =   RideRequestViewRequestingBehavior(presentingViewController: self, loginManager: loginManager)
  requestBehavior.modalRideRequestViewController.delegate = self
  let builder = RideParametersBuilder()    
builder.setDropoffLocation(propertyLocation!, address: property?.address)
  let rideParameters =
  let btn  = RideRequestButton(rideParameters: rideParameters, requestingBehavior: requestBehavior)
  return btn

And add it to my view:

private func addUberButton() {
  uberButton = buildRideRequestWidgetButton(.Native)
uberButton?.colorStyle = .White

Now, as long as you have followed the instructions for configuring your Xcode project to auth correctly with Uber, when you run your app, you should see something like this:

Ride Request button in Dreamhouse sample app

Using geo-location fields in Salesforce provides a lot of potential to add context to your mobile apps, and also makes it easy to improve the experience of these apps by connecting them with apps users already use every day, like Uber. This pattern of linking between apps is a very powerful way of leveraging the best that multiple platforms like Salesforce, or Uber, or dozens of others, can provide.

The complete controller code for the sample above can be found here, with the entire app’s code here.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.