[英]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.