WebPushError:收到意外的响应代码 - GCM

时间:2016-09-22 09:46:02

标签: google-cloud-messaging web-push progressive-web-apps

我正在使用网络推送为应用启用推送通知。

webPush.setGCMAPIKey('我的-GCM-API密钥&#39);

app.post('/sendNotification', function(req, res) {
      console.log(req.body)
      payloads[req.body.endpoint] = req.body.payload;
      webPush.sendNotification(req.body.endpoint
       , {
         TTL: req.body.ttl,
       }
      )
      .then(function() {
          console.log('mest')
        res.sendStatus(201);
      })
      .catch(function(err){
          console.log(err)
      });
  });

我在sendNotification api调用期间遇到错误。

{ [WebPushError: Received unexpected response code]
  name: 'WebPushError',
  message: 'Received unexpected response code',
  statusCode: 400,
  headers:
   { 'content-type': 'text/html; charset=UTF-8',
     date: 'Thu, 22 Sep 2016 09:22:31 GMT',
     expires: 'Thu, 22 Sep 2016 09:22:31 GMT',
     'cache-control': 'private, max-age=0',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'SAMEORIGIN',
     'x-xss-protection': '1; mode=block',
     server: 'GSE',
     'alt-svc': 'quic=":443"; ma=2592000; v="36,35,34,33,32"',
     'accept-ranges': 'none',
     vary: 'Accept-Encoding',
     connection: 'close' },
  body: '<HTML>\n<HEAD>\n<TITLE>UnauthorizedRegistration</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>UnauthorizedRegistration</H1>\n<H2>Error 400</H2>\n</BODY>\n</HTML>\n' }

如果有人遇到这个问题,请告诉我。

0 个答案:

没有答案