[英]UIApplication.shared.open is not working in ios 13
I am trying to open google map, but the following code is not working in ios 13.我正在尝试打开谷歌地图,但以下代码在 ios 13 中不起作用。
let addressForMap = address.replacingOccurrences(of: " ", with: "+", options: .literal, range: nil)
if let url = URL(string: "comgooglemaps://?q=\(addressForMap)¢er=\(lat),\(long)") {
if #available(iOS 10, *) {
UIApplication.shared.open(url, options: [:],
completionHandler: {
(success) in
print("Open: \(success)")
})
} else {
let success = UIApplication.shared.openURL(url)
print("Open: \(success)")
}
}
In plist, I have added it:在 plist 中,我添加了它:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>googlechromes</string>
<string>comgooglemaps</string>
</array>
Your url might be return nil, so they not open in browser or google map Please try url您的网址可能会返回 nil,因此它们无法在浏览器或谷歌地图中打开 请尝试 url
if let url = URL(string: "comgooglemaps://?saddr=&daddr=\(latitude),\(longitude)&directionsmode=driving") {
UIApplication.shared.open(url, options: [:])
}
Your try this url also你也试试这个网址
"https://maps.google.com/?q=@\(lat),\(lon)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.