使用Firebase FCM时,为什么不能收起推送通知? [英] Why can't I collapse my push notifications when I use Firebase FCM?
本文介绍了使用Firebase FCM时,为什么不能收起推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
const options = {
priority: 'high',
collapseKey: user_id
};
const deviceTokensPromise = db.ref('/users-fcm-tokens/' + user_id).once('value');
deviceTokensPromise.then(tokensSnapshot => {
if (!tokensSnapshot.hasChildren()) {
return console.log('There are no device tokens to send to.');
}
const tokens = Object.keys(tokensSnapshot.val());
console.log(tokens);
console.log(payload);
return admin.messaging().sendToDevice(tokens, payload, options).then(response => {
console.log(response);
return removeInvalidFCMTokens(tokensSnapshot, response);
});
});
我的选项中有一个折叠键字段.
I have a collapse-Key field in my options.
运行此代码后,iPhone会收到多个通知,且所有通知都相互叠加.我希望最近的通知取代以前的通知.
When this code is ran, the iPhone receives multiple notifications, all on top of each other. I'd like to have most recent notification replace the previous ones.
推荐答案
查看全文