Open uber from my application with a send and drop place pre-populated without using sdk

I want to open uber with the click of a button in my application with filling in the pickup and drop-down menu without using uber sdk. I followed a link that suggests deep binding, but it doesn’t work: https://developer.uber.com/docs/riders/ride-requests/tutorials/deep-links/introduction

Below is my code

Uber was added first, as here:

<key>LSApplicationQueriesSchemes</key> <array> <string>uber</string> </array> 

Then he added this piece of code to the button action:

 let url = NSURL(string: "uber://?client_id=oR5_kM9B8Hsxf9BKAXZl7Pm6IcL38n9w&action=setPickup&pickup[latitude]=37.775818&pickup[longitude]=-122.418028&pickup[nickname]=UberHQ&pickup[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103&dropoff[latitude]=37.802374&dropoff[longitude]=-122.405818&dropoff[nickname]=Coit%20Tower&dropoff[formatted_address]=1%20Telegraph%20Hill%20Blvd%2C%20San%20Francisco%2C%20CA%2094133&product_id=a1111c8c-c720-46c3-8534-2fcdd730040d&link_text=View%20team%20roster&partner_deeplink=partner%3A%2F%2Fteam%2F9383") if UIApplication.shared.canOpenURL(url! as URL){ UIApplication.shared.openURL(url! as URL) } 

I was just just trying to open uber from my application, even if it doesn't work. Please suggest some solution. Thanks in advance!

+5
source share
1 answer

Try the following:

 <key>LSApplicationQueriesSchemes</key> <array> <string>uber</string> </array> let url = URL(string: "uber://?client_id=oR5_kM9B8Hsxf9BKAXZl7Pm6IcL38n9w&action=setPickup&pickup[latitude]=37.775818&pickup[longitude]=-122.418028&pickup[nickname]=UberHQ&pickup[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103&dropoff[latitude]=37.802374&dropoff[longitude]=-122.405818&dropoff[nickname]=Coit%20Tower&dropoff[formatted_address]=1%20Telegraph%20Hill%20Blvd%2C%20San%20Francisco%2C%20CA%2094133&product_id=a1111c8c-c720-46c3-8534-2fcdd730040d&link_text=View%20team%20roster&partner_deeplink=partner%3A%2F%2Fteam%2F9383") if UIApplication.shared.canOpenURL(url!){ if #available(iOS 10.0, *) { UIApplication.shared.open(url!, options: [:], completionHandler: { (success) in if success { print("Successfully open uber") } }) } else { // Fallback on earlier versions } } else{ print("app not found") } 
+2
source

Source: https://habr.com/ru/post/1271218/


All Articles