【发布时间】:2018-01-02 01:24:15
【问题描述】:
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);
});
});
我的选项中有一个折叠键字段。
运行此代码时,iPhone 会收到多个通知,所有通知相互叠加。我想让最近的通知替换以前的通知。
【问题讨论】:
-
我已经更新了我的答案,请看下文。
标签: firebase push-notification apple-push-notifications firebase-cloud-messaging