0

This is a very amateur question.

The following is a code to check if google maps exists on an iOS device, as mentioned on the google maps iOS url scheme page.

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://");
    }

I am making a mobile website and I don't know where to place this. In my JavaScript file?

Please help. Thanks in advance.

batman
  • 1,937
  • 2
  • 22
  • 41
Rishi
  • 45
  • 9

1 Answers1

2

The above code is Objective-C and is only for checking within iOS apps. For websites, the solution is to attempt a redirect to the app url (comgooglemaps://) and if it's fails then the app is not installed.

See more details at the following answer: How to check if an app is installed from a web-page on an iPhone?

Community
  • 1
  • 1
NigelG
  • 651
  • 4
  • 7