You can force to open the selected application using a Universal link (iOS) / App link (Android) and it should force the selected app to be opened. Of course, If the application you want to launch is not found in the device it will open it in the browser.
Here I assume that you are using latitude and longitude to navigate to the place but you can easily adjust it to something else.
I am also using the url_launcher to launch the links.
void launchWaze(double lat, double lng) async {
var url = 'waze://?ll=${lat.toString()},${lng.toString()}';
var fallbackUrl =
'https://waze.com/ul?ll=${lat.toString()},${lng.toString()}&navigate=yes';
try {
bool launched =
await launch(url, forceSafariVC: false, forceWebView: false);
if (!launched) {
await launch(fallbackUrl, forceSafariVC: false, forceWebView: false);
}
} catch (e) {
await launch(fallbackUrl, forceSafariVC: false, forceWebView: false);
}
}
void launchGoogleMaps(double lat, double lng) async {
var url = 'google.navigation:q=${lat.toString()},${lng.toString()}';
var fallbackUrl =
'https://www.google.com/maps/search/?api=1&query=${lat.toString()},${lng.toString()}';
try {
bool launched =
await launch(url, forceSafariVC: false, forceWebView: false);
if (!launched) {
await launch(fallbackUrl, forceSafariVC: false, forceWebView: false);
}
} catch (e) {
await launch(fallbackUrl, forceSafariVC: false, forceWebView: false);
}
}
You also need to add the following to your Info.plist file:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>googlechromes</string>
<string>comgooglemaps</string>
<string>waze</string>
</array>