将Whatsapp业务API与Flutter应用程序集成

mklgxw1f  于 2022-11-17  发布在  Flutter
关注(0)|答案(1)|浏览(182)

我想整合Whatsapp for business API和Flutter应用程序。我从哪里开始,这是可能的吗?谢谢。

68bkxrlz

68bkxrlz1#

您可以使用来自Dart的flutter_share_me插件,并从Android清单中实现一些插件设置,需要将Kotlin更新到最新版本,然后才能正常打开Whatsapp Business APP。
下面是一些代码片段,可以帮助您:
使用Share.whatsapp_business切换案例

Future<void> onButtonTap(Share share, CustomerDetails customerDetails) async {
    String msg = "Thank you for contacting us! We will be in touch shortly";
    //"Customer Name : "+customerDetails.customerName.toString()+"\n"+"Address : "+customerDetails.address+"\n"+"Mobile No. : " + customerDetails.contactNo1.toString();
   String url = 'https://pub.dev/packages/flutter_share_me';

String response;
final FlutterShareMe flutterShareMe = FlutterShareMe();
switch (share) {
  case Share.facebook:
    response = await flutterShareMe.shareToFacebook(url: url, msg: msg);
    break;
  case Share.twitter:
    response = await flutterShareMe.shareToTwitter(url: url, msg: msg);
    break;

  case Share.whatsapp_business:
    response = await flutterShareMe.shareToWhatsApp4Biz(msg: msg);
    break;
  case Share.share_system:
    response = await flutterShareMe.shareToSystem(msg: msg);
    break;
  case Share.whatsapp_personal:
    response = await flutterShareMe.shareWhatsAppPersonalMessage(
        message: msg, phoneNumber: '+91'+customerDetails.contactNo1);
    break;
  case Share.share_telegram:
    response = await flutterShareMe.shareToTelegram(msg: msg);
    break;
}
debugPrint(response);
}

相关问题