gpt4 book ai didi

firebase - Flutter中的Fcm背景通知

转载 作者:行者123 更新时间:2023-12-03 03:54:51 27 4
gpt4 key购买 nike

我已经使用Firebase消息传递在后台实现了通知。但是,问题是这样的;如何将数据从功能myBackgroundMessageHandler返回到FirebaseNotification?

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
return Future<void>.value();
}

class FirebaseNotifications {
FirebaseMessaging _firebaseMessaging;
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

void setUpFirebase() {
_firebaseMessaging = FirebaseMessaging();
}

void fcmListeners() {
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("OnMessage");
processNotification(message);
return;
},
onBackgroundMessage: myBackgroundMessageHandler,
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch");
processNotification(message);
return;
},
onResume: (Map<String, dynamic> message) async {
print("onResume");
processNotification(message);
return;
},
);
}

processNotification(message) {}
}

最佳答案

目前,fireflutter库中存在一个错误。即使使用静态或全局变量,也无法从代码中访问变量。

在这里看看:

https://github.com/FirebaseExtended/flutterfire/issues/1878

关于firebase - Flutter中的Fcm背景通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61751674/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com