Can a progressive web app (PWA) run a background service on a mobile device to get data from hardware (accelerometer, gps…)?

The modern method of running code “in the background” is by using a service worker, either via its push event handler (triggered via an incoming push message), or via its sync event handler (triggered by an automatic replay of a task that previously failed).

It’s not currently possible to access the type of hardware sensors that you’re asking about from inside a service worker.

Leave a Comment