Question

So according to google maps they've developed a urlscheme with a call back . How can i implement this ( going in to google map , and going back into my app?). Using this :

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

edit : nevermind should have kept reading their documentation.

Was it helpful?

Solution

You need to keep reading. It looks like your example cam straight from the google map iOS documentation. If you keep reading that document, down around the bottom, it explains the importance of using x-source and x-success to specify the callback URL.

You need to determine what your callback URL will be. In the documentation, they use sourceapp://?resume=true as the URL. If you use that, you then need to register the URL scheme with your Xcode project.

Click on your project, then go to the INFO tab, and look down for "URL Types" and you will then add your app's URL scheme. In this case, it would be sourceapp.

Now, whenever a URL starts with sourceapp:// your app delegate will be notified. So, you need to handle the URL call, by providing an implementation for the APP Delegate method:

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top