pwa消息推送报错?
根据教程写了这么一段代码:
app.post('/register', jsonParser, function(req, res) {
var endpoint = req.body.endpoint
var key = req.body.key
var authSecret = req.body.authSecret
console.log(saveSubscriptionToDatabase)
//保存用户注册信息
//这个方法是哪里来的?
saveRegistrationDetails(endpoint, key, authSecret)
console.log(11)
const pushSubscription = {
endpoint: req.body.endpoint,
keys: {
auth: req.body.authSecret,
p256dh: req.body.key
}
}
var body = "thank u for registering"
var iconUrl = "/icon.png"
//推送消息
webpush.sendNotification(pushSubscription,
JSON.stringify({
msg: body,
url: "http://localhost:3001/pwa",
icon: iconUrl
})
).then( response => {
res.sendStatus(201)
}).catch(err => {
console.log(err)
})
})
saveRegistrationDetails主要原因是,这个方法不知道哪里来的。。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论