【问题标题】:Can't open google map无法打开谷歌地图
【发布时间】:2018-01-15 08:01:16
【问题描述】:

我使用以下 swift 代码,但它每次都打印“无法使用 comgooglemaps://”。我在真正的 iphone7 中测试它并安装了谷歌地图应用程序。 请帮忙。

if UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
   UIApplication.shared.open(URL(string:"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic")!)
} else {
   print("Can't use comgooglemaps://")
}

【问题讨论】:

  • @AndreaMugnaini 是的

标签: ios swift google-maps deep-linking applinks


【解决方案1】:

必须定义密钥LSApplicationQueriesSchemes,因此在您的Info.plist 中应该有以下内容:

如果您想手动更改,可以添加:

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

您可以在Step 7: Declare the URL schemes used by the API查看官方文档:

从 iOS 9 和 Xcode 7 开始,应用必须通过在应用的 Info.plist 文件中指定方案来声明它们打算打开的 URL 方案。 Google Maps SDK for iOS 会在用户点击地图上的 Google 徽标时打开 Google Maps 移动应用,因此您的应用需要声明相关的 URL 方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多