描述 客户已集成 Firebase Messaging,Android 平台 Flutter IM SDK 的不触发任何回调。
分析(根因分析、需求分析) 可能原因是客户构建了一个 FlutterEngine instance,导致 SDK 的 FlutterEngine instance 失效了。
解决方案 找到以下 java 文件 packages/firebase_messaging/firebase_messaging/android/src/main/java/io/flutter/plugins/firebase/messaging/FlutterFirebaseMessagingBackgroundExecutor.java
修改代码如下:
if (shellArgs != null) {
Log.i(
TAG,
"Creating background FlutterEngine instance, with args: "
- Arrays.toString(shellArgs.toArray()));
// 1. 修改此处如下
// backgroundFlutterEngine =
// new FlutterEngine(
// ContextHolder.getApplicationContext(), shellArgs.toArray());
backgroundFlutterEngine =
new FlutterEngine(
ContextHolder.getApplicationContext(), shellArgs.toArray(), false);
} else {
Log.i(TAG, "Creating background FlutterEngine instance.");
// 2. 修改此处如下
// backgroundFlutterEngine =
// new FlutterEngine(ContextHolder.getApplicationContext());
backgroundFlutterEngine =
new FlutterEngine(ContextHolder.getApplicationContext(), null, false);
} 详情查看:https://www.rongcloud.cn/?utm_source=SEO&utm_term=helloworld