19

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!

5
  • 2
    Another option, I guess, if you have a central server (for fleet management etc) is to NOT postMessage to Mainline App but instead just XHR/Fetch the location change to the server and then, when the Web App gains focus, it can just do a call to the server +/- a getCurrentLocation() Commented May 29, 2017 at 1:10
  • 2
    Do you have the service worker being updated with GPS, already? I have been searching for geofencing and updating via service worker for a bit. You are the first account I've encountered of someone actually doing it, and I'd like to ask if you would share your sources. Are you using native functionality, a plugin or third party resource? Commented May 31, 2017 at 13:33
  • @Jay That part of my question is wishful thinking or "fake news" I'm afraid :-( My question still applies to any Service Worker using postMessage() to queue messages for the client to be actioned when it is foregrounded again. The bounty will still apply but my real motivation for posting here is to raise awareness of Service Worker issue 745 github.com/w3c/ServiceWorker/issues/745#issuecomment-304168724 Please add you comments/wishes there. Let's get background GeoLocation into Usurper Web Apps now! Commented May 31, 2017 at 14:34
  • See little Web App. drive.google.com/open?id=0B7Rmd3Rn8_hDNW1zSWRoXzBTclU (There is a aaa_readme.txt) for some example/demo code Commented Aug 24, 2017 at 4:48
  • 1
    @martinjn Can I ask why you had to close this topic after 8 months? Commented Jun 6, 2018 at 8:43

1 Answer 1

11

My Brotkrumen Ultimate Web App is now complete. All source/image files can be found at https://drive.google.com/open?id=0B7Rmd3Rn8_hDNW1zSWRoXzBTclU

Most important design/proposed-specification change is that TravelManager subscription should now be Client specific. The TravelEvent must contain the intended Client.id (TravelEvent.source.id). This means that the UA must monitor and filter GeoLocation updates per client. I have also added new demo functionality such as a Trip Summary that is displayed when you press the "Arrive" button. The trip can also be replayed onto Google Maps by pressing "Map Trip" or "Replay". If the last and next geolocation updates for the trip are both visible in the Map window then smooth Marker movement is achieved via CSS transitions.

PLEASE help Background GeoLocation get up and help Web Apps compete with Native Apps!

If there is something wrong with my TravelManager solution design then let me know. Tear holes in it!

Sign up to request clarification or add additional context in comments.

6 Comments

So Location Update cannot be used while in background? Because I read in the readme it says foreground only.
Sad but true :-( Unless W3C or IETF or Browser vendors see the sense of my TravelManger solution then we're doomed to be 2nd class citizens to native apps.
I wonder if someone developed a browser that actually allows this how hard would it be to get it to the app stores
UPDATE 2021-04 There is a new API in discussion, "Geotracking", that will allow for background tracking. The issue needs votes, though. If you are interested in doing so, go here: bugs.chromium.org/p/chromium/issues/detail?id=898536
That "discussion" has gone the sme way as ll the others :-(
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.