Skip to content

Instantly share code, notes, and snippets.

@joseadrian
Last active August 29, 2015 14:02
Show Gist options
  • Save joseadrian/3c7cb771afc208956fb8 to your computer and use it in GitHub Desktop.
Save joseadrian/3c7cb771afc208956fb8 to your computer and use it in GitHub Desktop.
Open app if installed. If not, open store @source: https://www.waze.com/es-419/about/dev
try
{
String url = "waze://?q=Hawaii";
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
startActivity( intent );
}
catch ( ActivityNotFoundException ex )
{
Intent intent =
new Intent( Intent.ACTION_VIEW, Uri.parse( "market://details?id=com.waze" ) );
startActivity(intent);
}
- (void) navigateToLatitude:(double)latitude
longitude:(double)longitude
{
if ([[UIApplication sharedApplication]
canOpenURL:[NSURL URLWithString:@"waze://"]]) {
// Waze is installed. Launch Waze and start navigation
NSString *urlStr =
[NSString stringWithFormat:@"waze://?ll=%f,%f&navigate=yes",
latitude, longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
} else {
// Waze is not installed. Launch AppStore to install Waze app
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:@"http://itunes.apple.com/us/app/id323229106"]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment