PWA 关闭时发送通知
我使用 Angular 制作了一个 PWA 待办事项列表应用程序(链接到应用程序)。 我现在计划添加通知,以便在应用程序关闭时可以到达用户。 由于它是一个离线工作的 PWA,我不能依赖推送通知。 提前致谢
I have made a PWA Todo List App (Link To App) using Angular.
I am now planning on adding Notifications which can reach the user when the app is closed.
Since it is a PWA which works offline, I cannot depend on Push Notifications.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用Web周期性后台同步API您可以也可以离线运行此功能,即使应用程序已关闭,它也不需要后端服务器进行推送,因为它由服务工作人员定期(我猜至少 24 小时)
在您的项目文件中触发,注册同步事件:
在您的 Service Worker 文件中监听同步并显示 Web 通知:
注意 - 为了使用此定期同步 API,您需要先安装 PWA。
You can make use of Web Periodic Background Sync API You can run this feature offline too and even app is closed, it doesn't require backend server for push as it triggers by the service worker periodically (min 24 hr I guess)
in your project files register sync event:
in your service worker file listen to the sync and show web notification:
Note - In order to use this Periodic Sync API you need to install the PWA first.