gpt4 book ai didi

ios - 从我的应用程序打开优步,在不使用 sdk 的情况下预先填充上车和下车位置

转载 作者:搜寻专家 更新时间:2023-10-31 08:04:05 25 4
gpt4 key购买 nike

我想在不使用优步 SDK 的情况下通过点击我的应用程序中的按钮打开优步,并预填上车和下车地点。我点击了建议深层链接但不起作用的链接:https://developer.uber.com/docs/riders/ride-requests/tutorials/deep-links/introduction

下面是我的代码

首先在此处添加了 uber:

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

然后在按钮 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)
}

我也只是简单地尝试从我的应用程序中打开优步,即使这样也行不通。请提出一些解决方案。提前致谢!

最佳答案

试试这个:

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

关于ios - 从我的应用程序打开优步,在不使用 sdk 的情况下预先填充上车和下车位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45875098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com