0

使用 Firebase 发送推送通知后收到的响应的屏幕截图。我在第二个响应流中得到了 multicast_id、success:0 等。如何捕捉它? 第二个响应显示是否发送了推送通知。 如何捕捉它?

4

1 回答 1

0

找到答案了!!

  //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);
})
于 2017-04-29T05:02:27.223 回答