Google地图urlscheme不适用于iOS 9

以下URLscheme正在使用以前的版本,但不适用于iOS 9:

comgooglemaps://?q=Google+Japan,+Minato,+Tokyo,+Japan&center=35.660888,139.73073&zoom=15&views=transit 

在iOS 9上有什么变化,阻止应用程序使用URLscheme打开其他应用程序?

在iOS 9中,Apple对URLscheme的处理进行了更改。 现在你需要在plist中添加“LSApplicationQueriesSchemes”键,然后添加你想调用的URLScheme。

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

在iOS 9.0中,对canOpenURL方法进行了进一步的限制 – 为了使这种方法起作用,您需要在应用程序的info.plist文件中添加一个LSApplicationQueriesSchemes数组,然后为每个需要查询的URL scheme添加项目。 这些scheme可以作为comgooglemapscomgooglemaps-x-callback和您自己的应用的自定义urlscheme。

我在我的info.plist中添加了下列项目。

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

试试这个示例代码OpenInGoogleMaps-iOS 。