I'm having trouble launching a Google Maps app from within the iPhone app. While the app is installed on device, the code launches a Web version of the Google Maps in Safari. On the other hand, Apple Maps native app launches successfully.
Here is the code I'm using:
@IBAction func openMap(_ sender: Any) {
let lat: Double = -37.8218956215849
let long: Double = 144.9599325656891
let appleString = "https://maps.apple.com/?daddr=\(lat),\(long)" // Apple Maps - successfully launches an app
let googleString = "https://www.google.com/maps/dir/?api=1&destination=\(lat)%2C\(long)" // Google Maps - launches a Web version
let selectedString: String = googleString // Change accordingly
let url = URL(string: selectedString)!
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
I suppose, the problem is ridiculously simple, however I still haven't figured out how to fix it.
Update
Even the Google's example doesn't work on iOS 12 Beta 2:
https://developers.google.com/maps/documentation/urls/ios-urlscheme
, the issue might be linked with the usage of the Beta software.