This article explains how to use Universal Links to redirect your users to the Uber app. For a full guide on Uber's Deep Linking, please view the Uber Developer Guide on https://developer.uber.com/docs/riders/ride-requests/tutorials/deep-links/introduction


We're going to use the Universal Link provided by Uber, which is mentioned in the developer guide linked above.



Right, that's quite unreadable. Let's break it down to reveal the logic, and make it understandable!


The url consists of a base url "https://m.uber.com/ul/" followed by a question mark "?". The question mark indicates the start of a query, which is where we can define our query parameters. Query parameters are linked by an ampersand "&". Splitting the url above on the ampersand results in the following parameters:


  • client_id
  • action
  • pickup[latitude]
  • pickup[longitude]
  • pickup[nickname]
  • pickup[formatted_address]
  • dropoff[latitude]
  • dropoff[longitude]
  • dropoff[nickname]
  • dropoff[formatted_address]
  • product_id
  • link_text
  • partner_deeplink


After reading Uber's Developer Guide on Deep Linking, we found that the client_id is only used when using native app deep linking. Since we are using the Universal Link, we can remove the client_id from the query. And since we're removing things that are optional and / or not required, let's also kick out the product_id, link_text, and partner_deeplink. 


This leaves us with the following list of query parameters:


  • action
  • pickup[latitude]
  • pickup[longitude]
  • pickup[nickname]
  • pickup[formatted_address]
  • dropoff[latitude]
  • dropoff[longitude]
  • dropoff[nickname]
  • dropoff[formatted_address]


The action, latitude and longitude are required. In addition to these parameters, you will have to at least use the nickname OR the formatted_address are required. Using both is also allowed, but not required. The action will always be "setPickup", as we want to order an Uber to drive us places. 


In this example we are going to use the nickname parameter, as it can be set with a value of your choice. In addition to using the nickname parameter, we're going to use the following location and destination:


Location: My device's location. (In this case AppMachine HQ, Leeuwarden, the Netherlands)
Destination: Paddy O'Ryan. (An Irish Pub nearby)


The location of my device can be used as a parameter, by setting the "pickup[longitude]" to "my_location". The Uber app will automatically resolve this by using the device's location.


As for the destination: I've used an online lat long converter to get the lat long for Paddy O'Ryan, as I usually tend to forget the exact coordinates after a few beers. Of course linking it to a data-sheet can be done by using the {data:latitude} and {data:longitude} references, depending on your naming convention.


Let's populate our query parameters with the values we've stated above. As mentioned, we will leave out the "formatted_address" and only use the "nickname" parameter for now.


  • action=setPickup
  • pickup[latitude]=my_location
  • pickup[longitude]=my_location
  • pickup[nickname]=my_location
  • dropoff[latitude]=53.200893
  • dropoff[longitude]=5.800230
  • dropoff[nickname]=Paddy O'Ryan


Combining the query parameters above (using the ampersand "&"), and adding the base url, will result in the following Universal Link:


https://m.uber.com/ul/?action=setPickup&pickup[latitude]=my_location&pickup[longitude]=my_location&pickup[nickname]=my_location&dropoff[latitude]=53.200893&dropoff[longitude]=5.800230&dropoff[nickname]=Paddy%20O%27Ryan


Note that the url is encoded. This means Paddy O'Ryan becomes Paddy%20O%27Ryan.


Now that we have our encoded url, we can assign this url to be opened when the user clicks a button. To do so, we will use the logic functionality in AppMachine.


In this example we've added a Form block to our app with a single button. Clicking this button will open the Uber app, and allow me to order an Uber from my current location to a well deserved beer at Paddy O'Ryan's.


 


Navigate to the logic tab, and open the "btnSubmit.Click" logic actions.



Remove the current action if needed, and add a the action "Open Website". Provide the Universal Link we've set up earlier in the "Website url" field, and enable the "Open url in external browser" option.



The next step is to open the app, click the button, and get a ride to Paddy's. Which will look something like the screenshots below.


   


Note that in order for this to work, users have to have the Uber app installed on their device. If a user does not have the Uber app installed, the link will redirect them to the Uber website and prompt them to install the Uber app on their device as displayed in the screenshots below.