Skip to content

Commit 9acd3fb

Browse files
committed
bugfix
1 parent e81ca7c commit 9acd3fb

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

index.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,27 +204,31 @@ function FlamebaseDatabase(database, path) {
204204

205205
this.sendPushMessage = function(send) {
206206
this.queue.pushJob(function() {
207-
var message = {
208-
registration_ids: send.tokens, // required fill with device token or topics
209-
data: send.data,
210-
notification: send.notification
211-
};
212-
213-
if (object.debugVal) {
214-
logger.debug("Sending to: " + JSON.stringifyAligned(message.registration_ids));
215-
}
207+
return new Promise(function (resolve, reject) {
208+
var message = {
209+
registration_ids: send.tokens, // required fill with device token or topics
210+
data: send.data,
211+
notification: send.notification
212+
};
213+
214+
215+
if (object.debugVal) {
216+
logger.debug("Sending to: " + JSON.stringifyAligned(message.registration_ids));
217+
}
216218

217-
object.fcm.send(message)
218-
.then(function(response){
219-
if (object.debugVal) {
220-
logger.debug("Successfully sent with response: " + JSON.stringifyAligned(JSON.parse(response)));
219+
object.fcm.send(message)
220+
.then(function (response) {
221+
if (object.debugVal) {
222+
logger.debug("Successfully sent with response: " + JSON.stringifyAligned(JSON.parse(response)));
223+
}
224+
resolve();
225+
})
226+
.catch(function (err) {
227+
logger.error("error: " + JSON.stringifyAligned(err));
221228
resolve();
222-
}
223-
})
224-
.catch(function(err){
225-
logger.error("error: " + JSON.stringifyAligned(err));
226-
resolve();
227-
})
229+
})
230+
231+
});
228232
});
229233
};
230234

0 commit comments

Comments
 (0)