Xitao
Xitao

Reputation: 31

How can I open Google Maps URL Scheme on iOS?

AS google map SDK doc description, we can use the code below to call native google maps to finish directions. But how can I test these code on my Xcode? it always return "can't use comgooglemaps://"?

if ([[UIApplication sharedApplication] canOpenURL:
 [NSURL URLWithString:@"comgooglemaps://"]]) {
 [[UIApplication sharedApplication] openURL:
 [NSURL URLWithString:@"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];
 } else {NSLog(@"Can't use comgooglemaps://");
}

Upvotes: 3

Views: 5251

Answers (3)

guang
guang

Reputation: 76

If it is iOS 9 you might want to try this: under info custom iOS taget properties, LSApplicationQueriesSchemes. add comgooglemaps

enter image description here

Upvotes: 4

Paulw11
Paulw11

Reputation: 114773

Opening that URL requires the Google Maps app to be installed. You can't install apps from the app store on the simulator (they aren't compiled for x86 as a start), so you will need to test on an actual device

Upvotes: 0

joels
joels

Reputation: 1312

Apple Dev Notes say "NO if no app is available that will accept the URL; otherwise, returns YES."

Make sure you have Google Maps installed, not the default Apple maps App.

Upvotes: 0

Related Questions