【发布时间】:2019-01-11 04:29:04
【问题描述】:
我需要在我的 iOS 应用中打开谷歌地图。如果安装了谷歌地图,导航到谷歌地图,否则重定向到 AppStore 以安装谷歌地图。这是我的尝试
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
print("app found")
UIApplication.shared.open(URL(string: "comgooglemaps://?center=9.9894,76.5790&zoom=14&views=traffic&q=\(lattitude),\(longitude)")!, options: [:], completionHandler: nil)
}else {
showAlertWithTitle(title: "App not found", message: "You need to install Google Map", fromViewController: self)
print("Can't use comgooglemaps://")
}
【问题讨论】:
-
请添加您的代码或尝试
-
@SagarChauhan 如果安装了,我可以导航到谷歌地图。如果未安装,需要导航 AppStore 以安装谷歌地图
-
@SPatel 添加了我的代码。请检查
-
您是否在 info.plist 中添加了 LSApplicationQueriesSchemes ?看到这个developer.apple.com/documentation/uikit/uiapplication/…
标签: ios swift navigation