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

Flutter应用上线PlayStore后CallKit来电界面不显示,调试模式正常

解决方案:flutter_callkit_incoming在Play Store App Bundle中不显示来电界面

1. 适配Play App Signing与代码混淆

Play Store的应用签名机制会重签名应用,可能导致插件native逻辑异常,需做以下调整:

  • 升级flutter_callkit_incoming到最新版本(建议≥1.0.30),新版本已修复签名相关兼容问题
  • 若开启了代码混淆(minifyEnabled true),在android/app/proguard-rules.pro中添加插件的ProGuard规则:
# Flutter CallKit Incoming 保留规则
-keep class com.hiennv.flutter_callkit_incoming.** { *; }
-keep class androidx.core.app.** { *; }
-keep class android.app.** { *; }

2. 修正后台消息处理逻辑

你的_onBackgroundMessage存在重复调用showCallkitIncoming的问题,且后台环境中插件初始化可能有延迟,需优化:

Future<void> _onBackgroundMessage(RemoteMessage message) async {
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  try {
    final title = message.notification?.title ?? '';
    final body = message.notification?.body ?? '';
    if (body == "Incoming Video Call") {
      await showCallkitIncoming(Uuid().v4(), title, body);
    } else {
      print("Messaging notification");
    }
  } catch (e) {
    print('CallKit展示失败: $e');
  }
}

移除重复调用,添加异常捕获便于排查问题

3. 补充Android 12+权限与服务配置

Android 12及以上对前台服务和通知权限有更严格的限制:

  • 在AndroidManifest.xml中添加Android 13+的通知权限:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
  • 在<application>标签内为CallKit服务指定前台服务类型:
<service
    android:name="com.hiennv.flutter_callkit_incoming.CallKitService"
    android:foregroundServiceType="phoneCall" />

4. 检查App Bundle资源打包问题

你配置的backgroundUrl: 'assets/test.png'可能因App Bundle资源分包未被正确打包:

  • 确保pubspec.yaml中正确声明该资源:
flutter:
  assets:
    - assets/test.png
  • 可暂时注释backgroundUrl配置,测试是否因资源缺失导致CallKit无法展示

5. 提升Firebase消息优先级

后台消息优先级不足会导致无法及时唤醒应用处理CallKit:

  • 在云函数推送消息时,设置高优先级:
    • Android端:priority: "high"
    • iOS端:apns-priority: 5
  • 优先使用数据消息而非纯通知消息,纯通知消息在部分Android版本后台不会触发onBackgroundMessage

6. 模拟Play Store环境测试

不要直接依赖正式发布测试,用以下方式模拟Play Store环境:

  • 生成App Bundle后,用bundletool导出可安装APK:
bundletool build-apks --bundle=build/app/outputs/bundle/release/app-release.aab --output=app.apks
bundletool install-apks --apks=app.apks
  • 在真实设备上测试,确保环境与Play Store一致

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.01 06:45:30