Send Push neu

This commit is contained in:
Georg Reisinger
2019-02-24 05:42:54 +01:00
parent 507a44ddf8
commit f853a2bf0f
4 changed files with 40 additions and 26 deletions

View File

@ -0,0 +1,30 @@
var admin = require('firebase-admin');
var serviceAccount = require('../login/firebaseAdminKey.json');
var firebaseAdmin = admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://test-667ca.firebaseio.com'
});
function sendPush(msgtoken, title, text){
var message = {
notification: {
title: title,
body: text
},
token: msgtoken
};
firebaseAdmin.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);
});
}
module.exports = {
sendPush
}