TODO(slightlyoff): explain motivation for feature here.
Registering for a geofence is straightforward:
<!DOCTYPE html>
<!-- https://app.example.com/index.html -->
<html>
<head>
<script>
navigator.serviceWorker.register("/sw.js");
navigator.serviceWorker.whenReady().then(function(sw) {
// TODO
});
</script>
</head>
<body> ... </body>
</html>
Location notification happens from the Service Worker context via the new ...
event.
// sw.js
self.<...> = function(event) {
// TODO
};
// TODO
- Since Service Workers are a requirement for Geofencing, and since Service Workers are limited to HTTPS origins, sites served without encryption will always fail to register for fences.
- SW event handlers aren't allowed to run forever.