Search code examples
javascriptdjangogeolocationprogressive-web-appsbackground-sync

Django PWA - Periodic Background Sync


I have a django application (not yet PWA) in which I got asked to implement a feature that makes the app upload the users location to an API. This is because the app is used for truck operators. The client wants to be able to follow where the truck is. To monitor if all scheduled deliveries can be succeeded that day. My question: Is it possible to somehow make a background task that, even when the user is not using the app (its closed or not focussed), sends its location to the API? What technologies should I be using for this?

I have already looked into a lot of technologies (that for me are very new). Just as PWA (service workers), workers, periodic-background-sync-api, background-sync-api,... But I am getting lost in all the information that there exists.


Solution

  • I don't thinks this will work. Service workers can run in the background, but they cannot access the DOM, and the geolocation API is a DOM API. Meaning accessing a users geolocation won't work when the PWA is closed.