Search code examples
iosxcodeurlgoogle-maps-mobile

URL Scheme is Installed in iOS


I am Integrating Google Maps URL Scheme in my Application:

[[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]];

I am curios if there is some code to detect if Google Map isn't installed and redirect to App Store URL. Thanks for your Help.


Solution

  • If it return true, that means the Google Map app has been installed.

    if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]])
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/en/app/google-maps/id585027354?mt=8"]];
    else
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"comgooglemaps://"]];