【问题标题】:How to capture multicast response in Firebase push notifications?如何在 Firebase 推送通知中捕获多播响应?
【发布时间】:2023-03-04 12:39:01
【问题描述】:

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

【问题讨论】:

    标签: firebase push-notification google-cloud-messaging fetch-api web-notifications


    【解决方案1】:

    找到答案了!!

      //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);
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多