我一直在做google tutorial关于如何使用网页推送节点模块在Chrome上发送网页推送通知。网页推送API Chrome,返回“未经授权的注册”
问题是,本教程还提供了一个companion server app,您应该使用它来测试从服务器向客户端发送推送通知。
但是,在伴侣应用程序中,甚至在本地机器上使用网络推送cli时,尝试发送通知时,我都收到“未经授权注册”错误。 在网上找不到任何有关此错误的信息 - 我在做什么错误/缺失?
$ web-push send-notification --endpoint=https://fcm.googleapis.com/fcm/send/<<endpoint-key>>
Error sending push message:
{ [WebPushError: Received unexpected response code]
name: 'WebPushError',
message: 'Received unexpected response code',
statusCode: 400,
headers:
{ 'content-type': 'text/html; charset=UTF-8',
date: 'Fri, 25 Nov 2016 08:54:08 GMT',
expires: 'Fri, 25 Nov 2016 08:54:08 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"',
'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' }
你能解决这个问题吗? – michaeltintiuc
试试这个图书馆:https://github.com/emretekince/fcm-web-push –
真相对我来说似乎是:http://stackoverflow.com/a/42023959/813000 –