Reputation: 21
I'm using Uber and Lyft deeplink in my app. The functionality is that when user click the "ride with uber" or "ride with lyft" button, it will open Uber or Lyft app, and send pickup and destination coordinates to Uber/Lyft, and Uber/Lyft app will handle the trip.
I used standard deeplink for Uber. Everything works fine when Uber is already open and running in the background. When Uber is not in the background, the pickup location turns to be the user's current location (which is wrong, because the user wants to specify a pickup location, not necessarily the current location). This issue does not happen in Lyft though.
This is my code:
class ViewController: UIViewController {
@IBOutlet weak var uberBtn: UIButton!
@IBOutlet weak var lyftBtn: UIButton!
@IBAction func uberClicked(_ sender: Any) {
if isInstalledOf(app: "uber") {
open(scheme: "uber://?action=setPickup&client_id=7r6zjXf5e1p4nqYkX17d9R44estKs-na&product_id=a12ab23b-66f0-4028-9bb9-856dbcfdbbc7&pickup[formatted_address]=5874%20Newberry%20Street%2C%20Romulus%2C%20MI%2C%20USA&pickup[latitude]=42.265570&pickup[longitude]=-83.387391&dropoff[formatted_address]=15609%20Regina%20Avenue%2C%20Allen%20Park%2C%20MI%2C%20USA&dropoff[latitude]=42.253737&dropoff[longitude]=-83.211945")
} else {
open(scheme: "https://m.uber.com/ul/")
}
}
@IBAction func lyftClicked(_ sender: Any) {
if isInstalledOf(app: "lyft") {
open(scheme: "lyft://ridetype?id=lyft&pickup[latitude]=42.265570&pickup[longitude]=-83.387391&destination[latitude]=42.253737&destination[longitude]=-83.211945")
} else {
open(scheme: "https://www.lyft.com/signup/SDKSIGNUP?clientId=IcEuyAmFO7Gp&sdkName=iOS_direct")
}
}
// check if the app is installed
func isInstalledOf(app: String) -> Bool {
return UIApplication.shared.canOpenURL(URL(string: "\(app)://")!)
}
func open(scheme: String) {
if let url = URL(string: scheme) {
if #available(iOS 10, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
}
Upvotes: 1
Views: 700
Reputation: 86
Use Uber SDK and pass required parameters for deeplink. To resolve pickup location issue you need to pass pickup name and pickup address
let pickupLocation = CLLocation(latitude: <pickup latitude>, longitude: <pickup longitude>)
let dropoffLocation = CLLocation(latitude: <destination latitude>, longitude: <destination longitude>)
let builder = RideParametersBuilder()
builder.pickupLocation = pickupLocation
builder.pickupNickname = <pickup nickname>
builder.pickupAddress = <pickup address>
builder.dropoffLocation = dropoffLocation
builder.dropoffNickname = <dropof nickname>
builder.dropoffAddress = <dropof address>
builder.productID = productId
let deeplink = RequestDeeplink(rideParameters: builder.build(), fallbackType: .appStore)
deeplink.execute()
Upvotes: 1
Reputation: 21
I got confirmation(10/29/2018) from Uber that this issue is internal. This issue happens when Uber is not open, and Android does not has this issue. They are working on fixing this issue currently but unfortunately no ETA for now. Here is the message from Uber:
Thanks for the report. I see the issue on Github: https://github.com/uber/rides-ios-sdk/issues/249 … I can confirm the problem. It works correctly on Android but does not work correctly on IOS when the app is not open. Unfortunately no ETA but I will try and route this correctly internally.
Upvotes: 0