如何将我的应用程序中的位置发送到swift中的其他应用程序?

时间:2017-06-21 08:50:49

标签: swift location mapkit

enter image description here我的应用中有一个位置。我想制作一个按钮,将此位置发送到谷歌地图或waze等其他应用。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

创建一个像您已添加到图片中的ActionSheet。

对于列表中的所有应用程序,例如GoogleMaps,Maps,Waze 点击后执行以下操作..

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

}