简体   繁体   English

UIApplication.shared.open 在 ios 13 中不起作用

[英]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)&center=\(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.

相关问题 UIApplication.shared.open 仅适用于 https - UIApplication.shared.open only works with https UIApplication.shared.open添加标题数据 - UIApplication.shared.open Add Header Data UIApplication.shared.open, swift 完成一个连接处理 - UIApplication.shared.open , swift completion of a connection handling UIApplication.shared.open(url) 算作加密吗? - Does UIApplication.shared.open(url) count as encryption? iOS 14.5 或 14.6 及更高版本访问共享扩展中的 UIApplication.shared.open 或 UIApplication.shared.openURL 给出“APPLICATION_EXTENSION_API_ONLY” - iOS 14.5 or 14.6 onwards accessing UIApplication.shared.open or UIApplication.shared.openURL in Share Extension gives "APPLICATION_EXTENSION_API_ONLY" UIApplication.shared.open(_ url:URL等)没有打开任何东西 - UIApplication.shared.open(_ url: URL,etc.) doesn't open anything Gmail 有没有办法从 UIapplication.shared.open url 的文本中识别换行符 - Is there a way for Gmail to recognize line breaks from text from UIapplication.shared.open url 用户通知接收响应方法是否允许我将更新的变量传递给UIApplication.shared.open()? - User-Notification Did Receive Response Method Does not allow me to Pass Updated Variable to UIApplication.shared.open() ? Swift/iOS13 - UIApplication.shared.delegate.window?.rootViewController?.present() 来自自定义 class - Swift/iOS13 - UIApplication.shared.delegate.window?.rootViewController?.present() from custom class 在 swift 中为 iOS 13 打开与 UiApplication 的链接 - Opening a link with UiApplication in swift for iOS 13
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM