简体   繁体   中英

How to share my location from flutter app to whatsapp number?

I have a function that shared data to whatsapp number, but when sending a google location it`s not working.

when printing the URL that I get at this function: https://www.google.com/maps/search/?api=1&query=9.5191017,8.1450133

but I see that in WhatsApp look like: https://www.google.com/maps/search/?api=1

my code :

_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';
    }
}

my code that called the _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();
}

any one can help me how to share location in whatsapp app using flutter ? Thank you

我使用下面的代码解决了这个问题

final maps = Uri.https("google.com", "/maps/search/", { "api=1&query": "$lat,$lng" });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM