启动谷歌地图的Url模式在iOS 9中抛出警告,也不工作



下面的代码在iOS 8.4和更早的版本中工作正常,但从iOS 9.0开始,它开始抛出警告,并给出false总是

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps-x-callback://"]]

抛出警告:

-canOpenURL: failed for URL: "comgooglemaps-x-callback://" - error: "This app is not allowed to query for scheme comgooglemaps-x-callback"

有没有人知道,为什么它在iOS 9中失败,为什么抛出错误作为This app is not allowed to query for scheme comgooglemaps-x-callback,是否需要任何权限来查询它?

编辑

我在我的信息中添加了以下项目。点击,但仍然有同样的问题。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>comgooglemaps</string>
    <string>comgooglemaps-x-callback</string>
</array>

您必须在Info中添加一个LSApplicationQueriesSchemes条目。列出你希望应用程序查询的方案。

<key>LSApplicationQueriesSchemes</key>
<array>
     <string>urlscheme</string>
     <string>urlscheme2</string>
     <string>urlscheme3</string>
     <string>urlscheme4</string>
</array>

见http://useyourloaf.com/blog/querying-url-schemes-with-canopenurl.html(也包含相应WWDC15-Session-Video的链接)

相关内容

最新更新