You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter调用WhatsApp Business应用失败问题求助

解决Flutter无法启动WhatsApp Business的问题

以下是关键修复点和完整可行代码:

  • 规范号码格式
    必须使用带国际区号的纯数字格式,不能包含空格、括号或其他符号,例如正确格式为+8613xxxxxxxxx,而非13xxxxxxxxx或+86 13xxxxxxxxx。

  • Android端配置
    在android/app/src/main/AndroidManifest.xml的主<activity>标签内添加intent-filter,让系统识别WhatsApp Business的协议:

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="whatsapp-business" />
    </intent-filter>
    
  • iOS端配置
    在ios/Runner/Info.plist中添加LSApplicationQueriesSchemes,允许应用查询WhatsApp Business是否安装:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>whatsapp-business</string>
    </array>
    
  • 修正后的代码
    增加应用安装检测,并指定跳转模式为外部应用:

    import 'package:url_launcher/url_launcher.dart';
    
    Future<void> whatsAppBusiness(String phone) async {
      print(phone);
      final Uri whatsappUri = Uri.parse('whatsapp-business://send?phone=$phone');
      
      if (await canLaunchUrl(whatsappUri)) {
        await launchUrl(
          whatsappUri,
          mode: LaunchMode.externalApplication,
        );
      } else {
        print("WhatsApp Business未安装");
      }
    }
    

内容的提问来源于stack exchange,提问作者Ashirwad Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 15:30:00