Tag: 浏览器推送

WebPush UnauthorizedRegistration 400尝试从节点Js发送推送通知时出错

我正尝试使用来自NodeJS的Web Push发送推送通知。 以下是我在前端获取订阅的方式: swRegistration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: "SOME_APPLICATION_PUBLIC_KEY" })….. 这里是我用来发送推送通知的NodeJS: const webpush = require('web-push'); const options = { vapidDetails: { subject: 'mailto:SOME_MAIL_ID', publicKey: 'SOME_PUBLIC_KEY', privateKey: 'SOME_PRIVATE_KEY' } }; const pushSubscription = {"endpoint":"https://fcm.googleapis.com/fcm/send/SOME_END_POINT","keys{"p256dh":"SOME VALUE","auth":"SOME_VALUE"}}; webpush.sendNotification(pushSubscription, "Test Notification", options) .then(function(response) { console.log(response) }) .catch(function(error) {console.log(error)}); 然后我得到一个400错误。 我已经交叉validation了我的gcm_sender_id和我的服务器密钥。 一切看起来不错,通知在Firefox中testing正常工作,并在Chrome中失败。 这是我得到的错误: name: 'WebPushError', message: 'Received unexpected response code', statusCode: […]