【问题标题】:Flutter MethodChannel Direct Share to WhatsappFlutter MethodChannel 直接分享到 Whatsapp
【发布时间】:2022-01-14 04:13:21
【问题描述】:

我应该如何配置 MethodChannel 以便我可以直接将媒体和文本发送到 Whatsapp?

[注意]我没有使用现有的分享包,因为我需要捕获目标收件人。

【问题讨论】:

    标签: android ios flutter whatsapp flutter-method-channel


    【解决方案1】:

    使用插件。

    url_launcher

    使用以下链接:https://api.whatsapp.com/send?phone=XXXXXXXXXXX(在 X 的位置输入您要联系的人的电话号码,包括国家代码,但不带 + 号。)

    RaisedButton(
      onPressed: () async => await launch(
         "https://wa.me/${number}?text=Hello"),,
      child: Text('Open Whatsapp'),
    

    ),

    或者

    您可以使用这个其他插件。

    whatsapp_unilink

    whatsapp_unilink 包可帮助您构建 HTTP 链接并为您提供惯用的 Dart 接口:

     import 'package:whatsapp_unilink/whatsapp_unilink.dart';
    import 'package:url_launcher/url_launcher.dart';
    
    launchWhatsApp() async {
      final link = WhatsAppUnilink(
        phoneNumber: '+001-(555)1234567',
        text: "Hey! I'm inquiring about the apartment listing",
      );
      await launch('$link');
    }
    

    【讨论】:

    • 您好,感谢您的回复。但我正在寻找与文本一起发送媒体(例如照片)。你有解决方案吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-11
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    • 2013-08-24
    相关资源
    最近更新 更多