问题
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?
回答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
}
来源:https://stackoverflow.com/questions/44671172/how-to-send-a-location-from-my-app-to-other-apps-in-swift