backend-manager 4.2.7 → 4.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -127,7 +127,12 @@ Module.prototype.processTokens = async function (note, options) {
|
|
|
127
127
|
});
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
+
// Sending using SDK
|
|
130
131
|
// https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices
|
|
132
|
+
|
|
133
|
+
// Manually sending
|
|
134
|
+
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send
|
|
135
|
+
// https://firebase.google.com/docs/cloud-messaging/migrate-v1#provide-credentials-manually
|
|
131
136
|
Module.prototype.sendBatch = async function (batch, note, id) {
|
|
132
137
|
const self = this;
|
|
133
138
|
|
|
@@ -147,8 +152,6 @@ Module.prototype.sendBatch = async function (batch, note, id) {
|
|
|
147
152
|
assistant.log(`batch`, batch);
|
|
148
153
|
assistant.log(`note`, note);
|
|
149
154
|
|
|
150
|
-
// Send the batch
|
|
151
|
-
// const response = await admin.messaging().sendToDevice(batch, note);
|
|
152
155
|
try {
|
|
153
156
|
const response = await admin.messaging().sendMulticast({
|
|
154
157
|
tokens: batch,
|
|
@@ -177,6 +180,25 @@ Module.prototype.sendBatch = async function (batch, note, id) {
|
|
|
177
180
|
assistant.error(`🚩🚩🚩🚩🚩 333 error ${id}`, e);
|
|
178
181
|
}
|
|
179
182
|
|
|
183
|
+
try {
|
|
184
|
+
const messages = batch.map(token => ({
|
|
185
|
+
token: token,
|
|
186
|
+
notification: {
|
|
187
|
+
title: 'Your Notification Title',
|
|
188
|
+
body: 'This is the notification message.'
|
|
189
|
+
},
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
const response = await admin.messaging().sendEach(messages);
|
|
193
|
+
|
|
194
|
+
assistant.log(`🚩🚩🚩🚩🚩 444 response ${id}`, response); // FLAG
|
|
195
|
+
} catch (e) {
|
|
196
|
+
assistant.error(`🚩🚩🚩🚩🚩 444 error ${id}`, e);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Send the batch
|
|
200
|
+
const response = await admin.messaging().sendToDevice(batch, note);
|
|
201
|
+
|
|
180
202
|
// Log
|
|
181
203
|
assistant.log(`Sent batch ID: ${id}, Success: ${response.successCount}, Failures: ${response.failureCount}`);
|
|
182
204
|
|