1
现在我的有效负载仅发送1个徽章数量,徽章数量的值不会增加。它仍然是1,即使你得到超过1个通知。如何使用Firebase云端功能增加徽章数量
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 => {
});
};
});
});
你不能只是做一个增量int,并设置const payLoad中的'badge'值等于那个? – Surreal
你的意思是我应该在xcode中包含增量int(swiftcode)。然后我应该在有效载荷中使用该变量。让我们说徽章:badgecount? – Lukayne
这可以工作,我甚至建议存储在JS中的var – Surreal