-2

enter image description hereI 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?

SinaSB
  • 175
  • 2
  • 11

1 Answers1

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