i have a question regarding to ServiceWorkers. I know that those Workers may be terminated by the user agent. Will a so terminated ServiceWorker be able to still receive Push Notifications and wake up to them?
If not, are there any information about how long the service is allow to run usually? I'm targeting Chrome on Desktop as well as Chrome Mobile.
I'm curious about how much i can rely on the workers and how much i can integrate them in my further apps.
Edit: What i really did not expected: If i go to this example and manually stop the Service Worker (should be equal to termination trough user agent) and then submit a push notification, the service worker gets resumed.
Therefore i assume that Push Notifications can wake up a terminated service worker. Is there any limitation?
答案 0 :(得分:1)
已终止的服务工作者仍然能够处理push
事件。当浏览器检测到来自Web推送服务器的传入推送通知(例如,Google云消息传递)时,浏览器将启动相应的服务工作者。传入的推送消息包括注册信息,允许浏览器确定要启动的特定服务工作者。
要使浏览器从Web Push服务器接收传入推送通知,需要满足一些要求。
在桌面操作系统上,需要运行实际的浏览器进程。因此,举例来说,如果您是OS X用户上的Chrome并退出Chrome,那么在您再次启动Chrome之前,您将无法接收任何推送通知。 (此时,一堆可能全部流入。)
在Android上,与Web Push服务器的连接是通过操作系统处理的,Chrome(我相信Firefox)不一定是"运行"为了处理传入的通知并启动正确的服务工作者。