Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

How to send a location from my app to other apps in swift?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...