node.js - 收到通知时如何在 react native/Node.js 中设置徽章?
问题描述
当用户收到通知时,我无法找出如何设置徽章(应用左上方的红色圆圈)。逻辑假设在前端还是后端?我使用 React Native 作为前端,使用 Node.js 作为后端,并使用 firebase 进行推送通知。
目前,通知有效,但未显示红色徽章。
收到通知时我的后端(Node.js)
const admin = require('firebase-admin');
const payload = {
notification: {
title: `Test`,
body: `Hi`,
// badge: 1 Throws error : Invalid JSON payload received. Unknown name
},
token: 'someFCMToken',
};
try {
await admin
.messaging()
.send(payload)
.then((response) => {
console.log(response + ' notification were sent successfully');
});
} catch (err) {
console.log(err);
}
解决方案
推荐阅读
- forms - MS-Access 2010 表单:字段不接受带有 2 个连字符的数据源
- mariadb - MariaDB 崩溃原因
- chai - cypress 的单个语句中的多个断言
- c - 用c写一个简单的Linux shell
- kotlin - Kotlin 协程的 Jacoco 代码覆盖率不正确
- batch-file - 仅当该目录存在批处理脚本时才在目录中查找最新的子文件夹
- tfsbuild - 使用 dotnet pack 将变量传递给 nuspec
- image - ExifTools - 从 URL 添加缩略图
- html - 如何在鼠标悬停在角度 6 中的另一个按钮/卡上时取消选择选定的卡/按钮?
- rust - 如何使用 BorrowMut 超特征访问特征默认方法中的结构字段?