android - FCM 不会堆叠类似的消息?
问题描述
我正在尝试堆叠类似的消息,而不是为每条相同的消息发送单独的通知。
下面是我的代码
const payload = {
notification: {
title: `added new report`,
body: change.after.data().report_title,
tag: "ReportLog",
},
data: {
click_action: "FLUTTER_NOTIFICATION_CLICK",
sound: "default",
status: "done",
},
};
const options = {
priority: "high",
collapseKey: "ReportLog",
};
await admin.messaging().sendToDevice(tokens, payload, options);
所以假设我一次又一次地发送相同的消息,而不是堆叠消息,旧通知被新通知替换
解决方案
On the server side you can "remember" the last notify and don't send another. (Bad idea)
On the client you can do the same. (Also bad idea) But the thing is, that the "remember" logic won't work if the app is the background, because the notify will be handled by the system and not by your logic in the app.
推荐阅读
- go - 需要更多输入或有关 binary.write 错误无效类型 xxx 的信息
- go - 将 context.Context 传递给在单独的 goroutine 中执行的闭包的最佳方法
- java - Java 和 mysql 数据库,更新值总是延迟
- java - 找到 int 和 double 的最大值?
- c++ - Visual Studio xtree _STL_VERIFY(this->_Getcont(), "cannot increment value-initialized map/set iterator");
- listview - Flutter 仅按需填充 ExpansionTile 数据(一个 Future 对象),而不是在初始化时
- office365 - 使用 CSOM 更改 SharePoint Online 365 和网站标题
- python - Python拆分字符串数组
- java - 如何在列表视图中实现 admob 奖励视频广告?
- mysql - 在 MySql 的同一个表中加入 2 选择查询