I have a location in my app. I want to make a button that sends this location to other apps like google maps or waze. How can I do that?
Asked
Active
Viewed 1,505 times
-2

SinaSB
- 175
- 2
- 11
-
try this: https://stackoverflow.com/a/42971577/5447966 – Vlad Khambir Jun 21 '17 at 08:51
-
That's not what I want. I want something like the photo I added. – SinaSB Jun 21 '17 at 09:00
1 Answers
1
Create a ActionSheet like you have added in image.
And for all the applications in the list like GoogleMaps,Maps,Waze do the following on click..
BOOL canHandle = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps:"]];
if (canHandle) {
UIApplication.shared.openURL(URL(string:
"comgooglemaps://?center=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)&zoom=14&views=traffic&q=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)")!
} else {
//show alert to install googlemaps
}

Saranjith
- 11,242
- 5
- 69
- 122