Попытка отправить сообщение с моего сервера - веб-клиенту, используя webpush, с этим в Nodejs на сервере.Nodejs Web-push Chrome Push Notification
webpush.sendNotification(body, 'Your Push Payload Text').then(console.log);
тело представляет собой строку с Params, необходимых в соответствии с: https://github.com/web-push-libs/web-push
{"endpoint":"https://android.googleapis.com/gcm/send/eeXCuiNccV4:APA91bEC-ddg6Iy9OUjtDHzcjFd30cBM_6etyclYe63FrBP_UTCOA_oCwwDhrw-ILp1VqjdQD34X-G4WQ4xNUKnafTz4mGJZcppOsp-_HRNUHRgKXaAdppgClo2JsDAXZQjqxdGd0wq3","keys":{"p256dh":"BE3z-LbXeW65M6xdFhkhbFY9tj_re7RjEIUZDBPOslT1MqIG7-vaxHoUeZY3JOgJ_EaLa1eoifzNX3mno2PgCNc=","auth":"ZYov_VdiE2KZU65wpJWi8Q=="}}
получаю эту ошибку:
{ WebPushError: Received unexpected response code
12:42 AM
at IncomingMessage.<anonymous> (/app/node_modules/web-push/src/web-push-lib.js:274:20)
12:42 AM
at emitNone (events.js:91:20)
12:42 AM
at IncomingMessage.emit (events.js:185:7)
12:42 AM
at endReadableNT (_stream_readable.js:974:12)
12:42 AM
at _combinedTickCallback (internal/process/next_tick.js:74:11)
12:42 AM
at process._tickCallback (internal/process/next_tick.js:98:9)
12:42 AM
name: 'WebPushError',
12:42 AM
message: 'Received unexpected response code',
12:42 AM
statusCode: 400,
12:42 AM
headers:
12:42 AM
{ 'content-type': 'text/html; charset=UTF-8',
12:42 AM
date: 'Tue, 17 Jan 2017 06:42:38 GMT',
12:42 AM
expires: 'Tue, 17 Jan 2017 06:42:38 GMT',
12:42 AM
'cache-control': 'private, max-age=0',
12:42 AM
'x-content-type-options': 'nosniff',
12:42 AM
'x-frame-options': 'SAMEORIGIN',
12:42 AM
'x-xss-protection': '1; mode=block',
12:42 AM
server: 'GSE',
12:42 AM
'alt-svc': 'quic=":443"; ma=2592000; v="35,34"',
12:42 AM
'accept-ranges': 'none',
12:42 AM
vary: 'Accept-Encoding',
12:42 AM
connection: 'close' },
12:42 AM
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',
12:42 AM
endpoint: 'https://android.googleapis.com/gcm/send/eeXCuiNccV4:APA91bEC-ddg6Iy9OUjtDHzcjFd30cBM_6etyclYe63FrBP_UTCOA_oCwwDhrw-ILp1VqjdQD34X-G4WQ4xNUKnafTz4mGJZcppOsp-_HRNUHRgKXaAdppgClo2JsDAXZQjqxdGd0wq3' }
Можете ли вы показать нам свой 'body' переменной? – Marco
Работает ли он в Firefox? – Marco
Любой успех? ... Я придерживался той же проблемы :(... (http://stackoverflow.com/questions/41870838/webpusherror-and-unauthorizedregistration-when-try-to-send-push-notification-to) –