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

女生的网名这么多〃 提交于 2019-12-18 04:34:05

问题


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:


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!



来源:https://stackoverflow.com/questions/44233409/background-geolocation-serviceworker-onmessage-event-order-when-web-app-regain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!