github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/static_source/admin/public/sw-dev.js (about) 1 // Receive push notifications 2 self.addEventListener('push', function (e) { 3 if (!( 4 self.Notification && 5 self.Notification.permission === 'granted' 6 )) { 7 console.log('notifications aren\'t supported or permission not granted!') 8 return; 9 } 10 11 if (e.data) { 12 try { 13 let message = e.data.json(); 14 self.registration.showNotification(message.title, { 15 body: message.body, 16 icon: message.icon, 17 actions: message.actions 18 }); 19 } catch (e) { 20 console.warn(e.data) 21 } 22 } 23 });