Service Worker recurring

2019-09-12 04:28发布

问题:

Can i make a service worker, that run in background and poll the server at specific interval and return response or show notification(push notification) when chrome browser is closed. I am working for a website, that ask for service worker permission and sync the request at specific intervals in background based on request received from server show the notification.

Edit 1: As of now i can see chrome is working on this, but the post is too old Dec 2015. They have written it that they will introduce it in first half of 2016. It is not available till yet.

We're aiming to ship background sync to a stable version of Chrome in the first half of 2016. But we’re also working on a variant, “periodic background sync”. This will allow you to request a “periodicsync” event restricted by time interval, battery state and network state. This would require user permission, of course, but it will also be down to the will of the browser for when and how often these events fire. E.g., a news site could request to sync every hour, but the browser may know you only read that site at 07:00, so the sync would fire daily at 06:50. This idea is a little further off than one-off syncing, but it’s coming.