This commit is contained in:
Georg Reisinger
2019-03-18 18:39:43 +01:00
parent 78997fdd83
commit 8b0a30c3cf
2 changed files with 9 additions and 24 deletions

View File

@ -1,8 +1,6 @@
var admin = require('firebase-admin');
function sendPush(msgtoken, title, text){
var message = {
notification: {
title: title,
@ -24,24 +22,9 @@ function sendPush(msgtoken, title, text){
}
function sendMultiplePush(message_ids, title, text){
console.log(message_ids)
var message = {
data: {
title: title,
body: text
},
tokens: message_ids
};
admin.messaging().sendMulticast(message)
.then(function(response) {
// See the MessagingDevicesResponse reference documentation for
// the contents of response.
console.log('Successfully sent message:', response);
})
.catch(function(error) {
console.log('Error sending message:', error);
});
for(var i = 0; i < message_ids.length; i++){
sendPush(message_ids[i], title, text);
}
}
module.exports = {
sendPush,sendMultiplePush