[英]How to share my location from flutter app to whatsapp number?
我有一个功能可以将数据共享到 whatsapp 号码,但是在发送谷歌位置时它不起作用。
打印我在此功能中获得的 URL 时: https://www.google.com/maps/search/?api=1&query=9.5191017,8.1450133
: https://www.google.com/maps/search/?api=1&query=9.5191017,8.1450133
但我在 WhatsApp 中看到它看起来像: https://www.google.com/maps/search/?api=1
: https://www.google.com/maps/search/?api=1
api https://www.google.com/maps/search/?api=1
我的代码:
_launchURL() async {
var phonenumber = numberphone.substring(1,10);
var url = 'https://wa.me/+972$phonenumber?text=$textToSend';
print(url);
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
我调用 _launchURL() 的代码
onPressed: () async{
Position position = await getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
textToSend='https://www.google.com/maps/search/?api=1&query=${position.latitude},${position.longitude}'.toString() ;
_launchURL();
}
任何人都可以帮助我如何使用 flutter 在 whatsapp 应用程序中共享位置? 谢谢
我使用下面的代码解决了这个问题
final maps = Uri.https("google.com", "/maps/search/", { "api=1&query": "$lat,$lng" });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.