Push Fix
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user