notification_show_dedicated.js (262B)
1 onmessage = async ev => { 2 if (ev.data !== "show") { 3 return; 4 } 5 const reg = await navigator.serviceWorker.getRegistration(); 6 const shown = await reg.showNotification("title").then( 7 () => true, 8 () => false 9 ); 10 self.postMessage({ shown }); 11 };