У меня есть документ firestore с токеном 5000+ пользователей, но лимит FCM равен 1000, как я могу отправить уведомление всем.
как я могу отправить 1000-1000, используя l oop кто-нибудь может помочь мне разобраться это.
var newData;
exports.articlenotification = functions.firestore
.document("Articles/{id}")
.onCreate(async (snapshot, context) => {
//
if (snapshot.empty) {
console.log("No Devices");
return;
}
newData = snapshot.data();
const deviceIdTokens = await admin
.firestore()
.collection("Tokens")
.where("article", "==", true)
.get();
var tokens = [];
for (var token of deviceIdTokens.docs) {
tokens.push(token.data().token);
}
var payload = {
notification: {
title: "New Article",
body: newData.title,
image: newData.image,
sound: "default"
}
};
try {
const response = await admin.messaging().sendToDevice(tokens, payload);
console.log("Notification sent successfully");
} catch (err) {
console.log(err);
}
});