self.addEventListener('push', function (e) { if (!(self.Notification && self.Notification.permission === 'granted')) { //notifications aren't supported or permission not granted! return; } if (e.data) { let msg = ''; try { msg = e.data.json(); }catch (e){ msg = e.data; } console.log(msg) e.waitUntil(self.registration.showNotification(msg.title, { body: msg.body, actions: msg.actions })); } });