URL 未打开时,Service Worker 未监听推送事件
Service worker not listening push event when the URL is not opened
我想将 service worker 集成到我的网络应用程序中,并发送几乎类似于 Facebook 的推送通知(即使 Faceook 未打开也发送通知)
当 https://my-app-url.com 在其中一个选项卡中打开时,我的服务工作者甚至推送事件都工作正常。来自服务器的任何推送事件都可以很好地向 UI 发送数据。在这种情况下,我可以看到 Service Worker 的状态。它显示 "activated and running " 状态。
但是当 URL 没有在任何浏览器选项卡中打开时,service worker 不监听推送事件,甚至 Service Worker 状态显示 "activated and stopped"。
任何人都可以在这里帮助我。是否期望将 Service worker 状态显示为 "activated and stopped"?
检查此 documentation 以检查您是否遗漏了什么。
从那里您将能够检查您的工作。
Adding Push Notifications to a Web App
What you'll learn
- How to subscribe and unsubscribe a user for push messaging
- How to handle incoming push messages
- How to display a notification
- How to respond to notification clicks
您可以查看此 SO post 了解更多详情。
我想将 service worker 集成到我的网络应用程序中,并发送几乎类似于 Facebook 的推送通知(即使 Faceook 未打开也发送通知)
当 https://my-app-url.com 在其中一个选项卡中打开时,我的服务工作者甚至推送事件都工作正常。来自服务器的任何推送事件都可以很好地向 UI 发送数据。在这种情况下,我可以看到 Service Worker 的状态。它显示 "activated and running " 状态。
但是当 URL 没有在任何浏览器选项卡中打开时,service worker 不监听推送事件,甚至 Service Worker 状态显示 "activated and stopped"。
任何人都可以在这里帮助我。是否期望将 Service worker 状态显示为 "activated and stopped"?
检查此 documentation 以检查您是否遗漏了什么。
从那里您将能够检查您的工作。
Adding Push Notifications to a Web App
What you'll learn
- How to subscribe and unsubscribe a user for push messaging
- How to handle incoming push messages
- How to display a notification
- How to respond to notification clicks
您可以查看此 SO post 了解更多详情。