Georg Reisinger f31b24afb9 Push
getMessageIds wurde der sql reperiert
in push wurde sendMultiplePush hinzugefügt, aber noch fehlerhaft
2019-03-18 18:05:11 +01:00

48 lines
1.0 KiB
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){
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);
});
}
module.exports = {
sendPush,sendMultiplePush
}