gpt4 book ai didi

ios - 打开谷歌地图应用程序以从另一个应用程序进行导航

转载 作者:搜寻专家 更新时间:2023-11-01 05:47:19 27 4
gpt4 key购买 nike

我尝试使用这些代码从我的应用程序打开谷歌地图应用程序

if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"comgooglemaps://")!)) {
UIApplication.sharedApplication().openURL(NSURL(string:
"comgooglemaps://?saddr=\(fromLatitude),\(fromLongitude)&daddr=\(toLatitude),\(toLongitude)&directionsmode=driving")!)
}else{
showAlert()
}

我已经在我的 iPhone 中安装了谷歌地图,但这段代码总是会转到其他部分

最佳答案

Launch Services (part of the Core Services framework in macOS) provides support for launching apps and matching document types to apps.

您应该将其包含在您的info.plist 文件中

<key>LSApplicationQueriesSchemes</key>
<array>
<string>googlechromes</string>
<string>comgooglemaps</string>
</array>

如果没有安装谷歌地图,您可以在浏览器中打开。

// if GoogleMap installed
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.openURL(NSURL(string:
"comgooglemaps://?saddr=\(fromLatitude),\(fromLongitude)&daddr=\(toLatitude),\(toLongitude)&directionsmode=driving")! as URL)

} else {
// if GoogleMap App is not installed
UIApplication.shared.openURL(NSURL(string:
"https://www.google.co.in/maps/dir/?saddr=\(fromLatitude),\(fromLongitude)&daddr=\(toLatitude),\(toLongitude)&directionsmode=driving")! as URL)
}

关于ios - 打开谷歌地图应用程序以从另一个应用程序进行导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48703398/

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