【发布时间】:2022-01-14 04:13:21
【问题描述】:
我应该如何配置 MethodChannel 以便我可以直接将媒体和文本发送到 Whatsapp?
[注意]我没有使用现有的分享包,因为我需要捕获目标收件人。
【问题讨论】:
标签: android ios flutter whatsapp flutter-method-channel
我应该如何配置 MethodChannel 以便我可以直接将媒体和文本发送到 Whatsapp?
[注意]我没有使用现有的分享包,因为我需要捕获目标收件人。
【问题讨论】:
标签: android ios flutter whatsapp flutter-method-channel
使用插件。
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');
}
【讨论】: