From 402620c77b10a60460ad598c23438cec0276b280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aure=CC=81lien=20Lemesle?= Date: Mon, 8 Feb 2016 11:25:53 +0000 Subject: [PATCH] add uber support --- CMMapLauncher/CMMapLauncher.h | 1 + CMMapLauncher/CMMapLauncher.m | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMMapLauncher/CMMapLauncher.h b/CMMapLauncher/CMMapLauncher.h index e9169df..ae9bf23 100644 --- a/CMMapLauncher/CMMapLauncher.h +++ b/CMMapLauncher/CMMapLauncher.h @@ -51,6 +51,7 @@ typedef NS_ENUM(NSUInteger, CMMapApp) { CMMapAppTheTransitApp, // The Transit App CMMapAppWaze, // Waze CMMapAppYandex, // Yandex Navigator + CMMapAppUber // Uber }; @interface CMMapLauncher : NSObject diff --git a/CMMapLauncher/CMMapLauncher.m b/CMMapLauncher/CMMapLauncher.m index ee53704..f7cf0e1 100644 --- a/CMMapLauncher/CMMapLauncher.m +++ b/CMMapLauncher/CMMapLauncher.m @@ -51,7 +51,10 @@ + (NSString *)urlPrefixForMapApp:(CMMapApp)mapApp { case CMMapAppYandex: return @"yandexnavi://"; - + + case CMMapAppUber: + return @"uber://"; + default: return nil; } @@ -182,6 +185,16 @@ + (BOOL)launchMapApp:(CMMapApp)mapApp url = [NSString stringWithFormat:@"yandexnavi://build_route_on_map?lat_to=%f&lon_to=%f&lat_from=%f&lon_from=%f", end.coordinate.latitude, end.coordinate.longitude, start.coordinate.latitude, start.coordinate.longitude]; } return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; + } else if (mapApp == CMMapAppUber) { + NSString *url = nil; + if (start.isCurrentLocation) { + url = [NSString stringWithFormat:@"uber://?action=setPickup&pickup=my_location&dropoff[latitude]=%f&dropoff[longitude]=%f&dropoff[nickname]=%@", end.coordinate.latitude, end.coordinate.longitude, [end.name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + + } else { + url = [NSString stringWithFormat:@"uber://?action=setPickup&pickup[latitude]=%f&pickup[longitude]=%f&dropoff[latitude]=%f&dropoff[longitude]=%f&dropoff[nickname]=%@", start.coordinate.latitude, start.coordinate.longitude, end.coordinate.latitude, end.coordinate.longitude, [end.name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + + } + return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; } return NO;