欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

flutter 分享到whatsapp

程序员文章站 2022-06-23 14:07:54
android无需额外配置ios:LSApplicationQueriesSchemes whatsappflutter :需要 url_launcher_launchWhatsapp() async {const url = "https://wa.me/?text=Your Message here";var encod...

android无需额外配置
ios:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>whatsapp</string>
</array>

flutter :
需要 url_launcher

_launchWhatsapp() async {
//直接对指定号码发送消息
// 参考: https://api.whatsapp.com/send?phone=$phone&text=${URLEncoder.encode(message, "UTF-8")}
//  const url = 'whatsapp://send?phone=$phone';
const url = "https://wa.me/?text=Your Message here";
var encoded = Uri.encodeFull(url);

if (await canLaunch(encoded )) {
  await launch(encoded );
} else {
  throw 'Could not launch $url';
}

本文地址:https://blog.csdn.net/u011272795/article/details/108876913

相关标签: flutter