如何快速将位置信息从我的应用发送到其他应用? [英] How to send a location from my app to other apps in swift?

查看:153
本文介绍了如何快速将位置信息从我的应用发送到其他应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中有位置.我想创建一个按钮,将该位置发送到其他应用,例如Google Maps或Waze.我该怎么办?

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?

推荐答案

像在图像中添加的一样创建一个ActionSheet.

Create a ActionSheet like you have added in image.

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

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

}

这篇关于如何快速将位置信息从我的应用发送到其他应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆