Background Geolocation ServiceWorker - onMessage Event order when Web App regains focus

Viewed 6424

For complete details, and a more lengthy description, please refer to this W3C Service worker issue.

This is my HTML5 Web App scenario: -

  • My Web App has been backgrounded and stuck in my pocket while I go for a ride
  • As I clock up the KMs my Service Worker(s) is regularly receiving GPS updates and invoking postMessage() to queue them up for my App to eventually plot on the Google map
  • At the end of the ride I order a beer and foreground the Web App so I can see where I've been, average speed, and so on.

My question are these: -

1) Will the Focus event fire before or after all of the Message events triggered by the ServiceWorkers?

2) If Focus is first will a setTimer(0,backlogCleared) suffice as a heuristic mechanism to establish "all background stuff dealt with"?

3) Is there anyway to collapse the postMessage() messages (al la mode Firebase's push notifications) so that only the last/current message is received?

4) If you have ideas about the permissions required to authorize background geolocation please add them over at W3C.

Cheers and good riding, running, sailing, driving!

1 Answers
Related