我正在使用这个库: https://github.com/web-push-libs/web-push/并且可以成功发送推送:
webPush.sendNotification(req.body.endpoint, {
TTL: req.body.ttl,
payload: req.body.payload,
userPublicKey: req.body.key,
userAuth: req.body.authSecret,
})
然而,当我尝试将.then
或.catch
链接到它时,我什么也得不到,空字符串。我的目标是能够从GCM / Firefox服务器获得有关推送是否成功的实际响应。我怎么能这样做?
答案 0 :(得分:0)
sendNotification
返回的承诺将在没有错误时解决,否则将被拒绝。
因此,如果您在then
分支机构,则推送成功。如果您在catch
分支机构,则不是。