Url 用于启动 Google 映射的架构在 iOS 9 中抛出警告并且也无法正常工作
Url schema for launching Google maps throwing Warning in iOS 9 and also not working
以下代码在 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
,是否需要任何权限来查询它?
编辑
我已经在我的 info.plist 中添加了以下项目,但它仍然有同样的问题。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
<string>comgooglemaps-x-callback</string>
</array>
您必须将 LSApplicationQueriesSchemes 条目添加到 Info.plist 并列出您希望应用查询的方案。
<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(还包含一个 Link 对应的 WWDC15-Session-Video)
以下代码在 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
,是否需要任何权限来查询它?
编辑
我已经在我的 info.plist 中添加了以下项目,但它仍然有同样的问题。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
<string>comgooglemaps-x-callback</string>
</array>
您必须将 LSApplicationQueriesSchemes 条目添加到 Info.plist 并列出您希望应用查询的方案。
<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(还包含一个 Link 对应的 WWDC15-Session-Video)