Georg Reisinger 8b0a30c3cf Push Fix
2019-03-18 18:39:43 +01:00

31 lines
706 B
JavaScript

var admin = require('firebase-admin');
function sendPush(msgtoken, title, text){
var message = {
notification: {
title: title,
body: text
},
token: msgtoken
};
admin.messaging().send(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);
});
}
function sendMultiplePush(message_ids, title, text){
for(var i = 0; i < message_ids.length; i++){
sendPush(message_ids[i], title, text);
}
}
module.exports = {
sendPush,sendMultiplePush
}