// this file must be placed in root importScripts('https://www.gstatic.com/firebasejs/4.6.1/firebase-app.js'); importScripts('https://www.gstatic.com/firebasejs/4.6.1/firebase-messaging.js'); firebase.initializeApp({ messagingSenderId: '813343642322', }); self.addEventListener('push', function (event) { const payload = event.data.json(); const title = payload.notification.title; const options = { body: payload.notification.body, icon: payload.notification.icon, data: payload.notification.click_action, }; event.waitUntil(self.registration.showNotification(title, options)); }); self.addEventListener('notificationclick', function (event) { event.notification.close(); event.waitUntil(clients.openWindow('/mobile/#' + (event.notification.data || ''))); });