gpt4 book ai didi

ios - 无法打开谷歌地图

转载 作者:搜寻专家 更新时间:2023-11-01 05:55:21 27 4
gpt4 key购买 nike

我使用以下 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://")
}

最佳答案

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

enter image description here

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

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

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

Beginning with iOS 9 and Xcode 7, apps must declare the URL schemes that they intend to open, by specifying the schemes in the app's Info.plist file. The Google Maps SDK for iOS opens the Google Maps mobile app when the user clicks the Google logo on the map, and your app therefore needs to declare the relevant URL schemes.

关于ios - 无法打开谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48258945/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com