I am working with the Uber API which uses uber://?...
URLs to deep link into the Uber native app. I am building a mobile website and I'm building one of these URLs as described here;
On iOS everything works fine but on Android the Uber app opens and only gets one of the parameters product_id
. So I think there is some issue with how I am encoding the URL and how the Android system is opening it. Here is my JS to build the URL:
uber.createURL = function() {
var params = {
"client_id": uber.CLIENT_ID,
"product_id": maps.product_id,
"pickup[latitude]": maps.noSurgeMarker.getPosition().lat(),
"pickup[longitude]": maps.noSurgeMarker.getPosition().lng(),
"dropoff[latitude]": maps.destMarker.getPosition().lat(),
"dropoff[longitude]": maps.destMarker.getPosition().lng(),
"pickup[formatted_address]": $('#pickup').val(),
"dropoff[formatted_address]": $('#destination').val()
};
var url = 'uber://?action=setPickup';
for (var key in params) {
if (params.hasOwnProperty(key)) {
url += ('&' + key + '=' + encodeURIComponent(params[key]));
}
}
return url;
};
I am then calling the following code to open the link:
var url = uber.createURL();
window.location.href = url;
Am I missing something obvious? Again, this works on iOS but not on Android. Also the strange thing is if I generate the URL using createURL
on a computer, send it over to my Android device using PushBullet, opening it works perfectly. But if I get the URL through Chrome for Android the Uber app opens and only has product_id
correct, not any of the pickup or dropoff parts.
Note: I already trued using jQuery's params
function but that didn't work any better, which is why I went to the manual for (var key in params) {...}
loop.