0

Screenshot of the responses which I am getting after sending push notification using Firebase. I am getting multicast_id, success:0 etc in the second response stream. how to capture it? The second response shows whether the push notification is delivered or not. How to capture it?

Rakesh Dadamatti
  • 53
  • 1
  • 1
  • 8

1 Answers1

0

Found the answer!!

  //This function to sends push notification to users
for (var i = 0; i <= endUsersList.length - 1; i++)
{
fetch('https://fcm.googleapis.com/fcm/send', {
    'method': 'POST',
    'headers': {
        'Authorization': 'key=' + key,
        'Content-Type': 'application/json'
    },
    'body': JSON.stringify({
        'notification': notification,
        'to': endUsersList[i]
    }),
}).then(function (response) {
    if (response.status !== 200) {
        console.log('Looks like there was a problem. Status Code: ' +
          response.status);
        return;
    }
    // Examine the text in the response  
    response.json().then(function (data) {
        console.log(data);
    });
}).catch(function (err) {
    console.log('Fetch Error :-S', err);
})
Rakesh Dadamatti
  • 53
  • 1
  • 1
  • 8