是否可以在Flutter中使用FCM实施通知分组/捆绑? [英] Is it possible to implement notification grouping/bundling using FCM in Flutter?
问题描述
我尝试实现这样的组通知 android组通知和 ios组通知.但是我做不到.我也尝试过 flutter_local_notification 插件.但这仅在应用打开时有效.在前景(onResume)和背景上不起作用.
I try to implement group notification like this android group notification and ios group notification. But I can't able to do it. I tried this flutter_local_notification plugin too. but this works only when app open. not working on foreground(onResume) and background.
void registerNotification() {
_fcm.configure(
onMessage: (Map<String, dynamic> message) {
return;
},
onResume: (Map<String, dynamic> message) {
return;
},
onLaunch: (Map<String, dynamic> message) {
return;
},
onBackgroundMessage: backgroundMessageHandler);
}
有效载荷
const payload = {
notification: {
title: title,
body: message,
},
data: {
click_action: "FLUTTER_NOTIFICATION_CLICK",
sound: "default"
},
android: {
priority: "high",
collapse_key: userName,//tried to add collapse_key for group notification
},
apns: {
headers: {
"apns-priority": "5",
},
},
token:token,
};
我看到了本机的答案,但是没有办法使用 firebase_messaging 插件
I saw the react-native answer for this, but there is no way to do the same thing using firebase_messaging plugin react native answer
推荐答案
如果要提交组,则需要订阅一个主题,在提及该主题的文档中,您将不再发送单个令牌,而是而是订阅一个主题并将其提交给该主题.
If you want to submit a group, you need to subscribe to a topic, in the documentation that mentions it, you would no longer send a single token, but would instead subscribe to a topic and submit it to that topic.
这篇关于是否可以在Flutter中使用FCM实施通知分组/捆绑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!