处理Chrome中过期的Web推送订阅

发布于 2025-02-02 08:44:36 字数 477 浏览 1 评论 0原文

我注意到Web推送订阅每天到期,我不确定如何处理重新订阅,因为Chrome不支持此事件

>

  • https://develover.mozilla.org.org/en-us/docs/docs/web/web/api/service/servicework-服务工作者并张贴在服务器上,存储在DB
  • Sever中,发送Web推动,
  • 第二天我尝试发送Web推动时,它可以使410消失,并带有消息“推送订阅未订阅或过期”。

如果我们知道订阅的寿命并在它到期之前续订它,那将非常有用,我没有找到与该

注释有关的任何内容:我正在使用此gem https://github.com/zaru/webpush 从服务器塞发送Web推动

I noticed that the web push subscription expires daily, I'm not sure how to handle the re-subscription since Chrome doesn't support this event https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/pushsubscriptionchange_event

Details:

  • a subscription is generated in the service worker and posted to the server, stored in the DB
  • sever sends web push, it works
  • next day when I try to send a web push I get the 410 Gone with the message "push subscription has unsubscribed or expired."

it would be super useful if we could know the lifespan of a subscription and renew it before it expires, I didn't find anything related to that

note: I'm using this gem https://github.com/zaru/webpush to send web push from the server-side

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文