目前我的负载只发送了一个徽章计数,即使你收到多个通知,徽章计数的值也不会增加。
应该如何编写JavaScript代码?
我目前的代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendPushForHelp =
functions.database.ref('/help/school/{id}').onWrite(event => {
const payLoad = {
notification: {
title: 'Someone',
body: 'needs help',
badge: '1',
sound: 'Intruder.mp3'
}
};
return admin.database().ref('fcmToken').once('value').then(allToken => {
if (allToken.val()) {
const token = Object.keys(allToken.val());
return admin.messaging().sendToDevice(token, payLoad).then(response => {
});
};
});
});
payLoad
中的badge
值设置为它? - Surreal