2 回答

TA贡献1804条经验 获得超2个赞
有两种方法可以做到这一点。第一种方式发送 1000 然后 1000 ..等等。第二种方式是发送到特定主题,所有订阅该主题的客户都会收到您的通知。
此代码发送 1000 然后 1000 ..etc。但我不喜欢它。你应该使用topic-messaging
它来代替它。
for (let i = 0; i < listOf5000Tokens.length; i += 1000) {
const listOf1000Tokens = listOf5000Tokens.slice(i, i + 1000);
// using await to wait for sending to 1000 token
await doSomeThing(listOf1000Tokens);
}

TA贡献1851条经验 获得超5个赞
您需要分批发送消息。
例如:
// Create a list containing up to 500 messages.
const messages = [];
messages.push({
notification: {title: 'Price drop', body: '5% off all electronics'},
token: registrationToken,
});
messages.push({
notification: {title: 'Price drop', body: '2% off all books'},
topic: 'readers-club',
});
admin.messaging()
.sendAll(messages)
.then((response) => console.log(response.successCount + ' messages were sent successfully'));
添加回答
举报