当前知识库站点已不再维护。请移步新版知识库:https://help.rongcloud.cn/

集成 Firebase 后,SDK 回调不触发

工程内集成 Firebase 库后, 原本 SDK 的回调逻辑无法触发
发布时间: 2023-03-21 09:51

回答:

  1. 找到 packages/firebase_messaging/firebase_messaging/android/src/main/java/io/flutter/plugins/firebase/messaging/FlutterFirebaseMessagingBackgroundExecutor.java 类

  2. 修改代码如下:


```

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);

}

```