2

My app uses openURL to open Google Maps app. It works on iOS 9 but not on iOS 10.

I understand that this method was deprecated on iOS 10, and there's a new one with more parameters. However, I saw everywhere that it should still work, and changing to the new method will only prevent a warning in the xCode. I also want to still support iOS 9 and lower.

Any help?

Thanks.

Rahul Mayani
  • 3,761
  • 4
  • 25
  • 40
Rotem Yakov
  • 181
  • 1
  • 12

1 Answers1

8

Add LSApplicationQueriesSchemes key in info.plist file.

<key>LSApplicationQueriesSchemes</key>
    <array>
     <string>comgooglemaps</string>
    </array>

Use this....

Objective c

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"comgooglemaps://maps.google.com/maps"] options:@{} completionHandler:nil];

Swift 4

 guard let url = URL(string: "comgooglemaps://maps.google.com/maps") else {
      return //be safe
 }

if #available(iOS 10.0, *) {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
   UIApplication.shared.openURL(url)
}
Rahul Mayani
  • 3,761
  • 4
  • 25
  • 40