···3636 }
3737}
38383939+let autoreg;
3940async function subscribeToPush() {
4041 const registration = await navigator.serviceWorker.register('/service-worker.js');
4242+4343+ // auto-update in case they keep it open in a tab for a long time
4444+ clearInterval(autoreg);
4545+ autoreg = setInterval(() => registration.update(), 4 * 60 * 60 * 1000); // every 4h
41464247 const subscribeOptions = {
4348 userVisibleOnly: true,