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

心已入冬 提交于 2019-12-13 09:48:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!