首页 > 解决方案 > 使用 openURL 的谷歌地图应用重定向问题

问题描述

我对谷歌地图有疑问。在我的设备中,没有安装谷歌地图,但我仍然取得了成功。有什么问题吗??????

@IBAction func clickedBtn(_ sender: Any) {

    let customURL = "comgooglemaps://"

    if UIApplication.shared.canOpenURL(URL(string: customURL)!) {

        print("Success")
        UIApplication.shared.open(URL(string: customURL)!, options: [:], completionHandler: nil)
    }
    else {
        let alert = UIAlertController(title: "Error", message: "Google maps not installed", preferredStyle: UIAlertController.Style.alert)
        let ok = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil)
        alert.addAction(ok)
        self.present(alert, animated:true, completion: nil)
    }
}

我还添加了 LSApplicationQueriesSchemes

在此处输入图像描述

标签: ios

解决方案


推荐阅读