Reputation: 3888
I am trying to get direction using google map. I am following this link https://developers.google.com/maps/documentation/ios-sdk/urlscheme?hl=en
and code:
if ([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]]) {
NSString *temp=@"comgooglemaps://?saddr=Google+Inc,+8th+Avenue,+New+York,+NY&daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York&directionsmode=transit";
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:temp]];
} else {
NSLog(@"Can't use comgooglemaps://");
}
the map is not opened,i am getting:
Installation[2918:1295695] -canOpenURL: failed for URL: "comgooglemaps://" - error: "(null)"
what was the problem? did i miss anything?
I want to show google map from my application.
Upvotes: 1
Views: 1705
Reputation: 992
Make sure Google Maps app is installed in your device before making the function call or else the canOpenURL: function will return null.
Upvotes: 0
Reputation: 1092
In iOS 9 you must whitelist any URL schemes your App wants to query in Info.plist under the LSApplicationQueriesSchemes key (an array of strings):
Quote taken from here http://useyourloaf.com/blog/querying-url-schemes-with-canopenurl.html
Upvotes: 1