【问题标题】:Uber deeplink pickup location issues on iOSiOS 上的 Uber 深度链接取货位置问题
【发布时间】:2019-03-27 21:51:29
【问题描述】:

我在我的应用中使用 Uber 和 Lyft 深度链接。其功能是当用户点击“乘坐优步”或“乘坐 lyft”按钮时,它将打开 Uber 或 Lyft 应用程序,并将上车和目的地坐标发送给 Uber/Lyft,由 Uber/Lyft 应用程序处理行程。

我为 Uber 使用了标准的深度链接。当 Uber 已经打开并在后台运行时,一切正常。当 Uber 不在后台时,上车地点变成用户当前位置(这是错误的,因为用户要指定上车地点,不一定是当前位置)。不过,这个问题在 Lyft 中不会发生。

这是我的代码:

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)
            }
        }
    }
}

【问题讨论】:

  • 尝试使用用户 SDK github.com/uber/rides-ios-sdk,而不是自己实现。调试起来很容易......如果不是,而不是使用深层链接,使用通用深层链接......
  • 我尝试使用 UberRides SDK 和通用深度链接,它们都无法解决这个问题 :( 一切正常,除了接送地点
  • 我想这是你创建的...github.com/uber/rides-ios-sdk/issues/249...这绝对看起来像是优步应用程序的一个错误...我会说坚持下去,除非优步有人回应..
  • 感谢您的链接。它不是我创建的,但我和他的问题完全相同。
  • 继续关注这个问题。如果它广泛传播,肯定会有人回应它。

标签: ios swift uber-api deeplink


【解决方案1】:

我从 Uber 得到确认(2018 年 10 月 29 日)这是内部问题。 Uber 未开通时会出现此问题,Android 不存在此问题。他们目前正在努力解决这个问题,但不幸的是目前没有 ETA。这是来自优步的消息:

感谢您的报告。我在 Github 上看到了这个问题: https://github.com/uber/rides-ios-sdk/issues/249 ...我可以确认 问题。它可以在 Android 上正常工作,但不能在 Android 上正常工作 IOS 应用程序未打开时。不幸的是没有预计到达时间,但我会尝试 在内部正确路由。

【讨论】:

【解决方案2】:

使用 Uber SDK 并传递深度链接所需的参数。要解决取件地点问题,您需要传递取件名称和取件地址

        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()

【讨论】:

  • 使用 Uber SDK 并传递深度链接所需的参数。要解决取件地点问题,您需要传递取件名称和取件地址。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-11
  • 2016-03-20
  • 2016-07-29
  • 2019-04-11
相关资源
最近更新 更多