import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.8.2/firebase-app.js'; import { getMessaging, experimentalSetDeliveryMetricsExportedToBigQueryEnabled } from 'https://www.gstatic.com/firebasejs/9.8.2/firebase-messaging-sw.js'; const firebaseApp = initializeApp({ apiKey: 'AIzaSyC7xCg9LEYqiDKkCBsjhMFg-MKTNakYuj8', authDomain: 'web-alerts-1194.firebaseapp.com', projectId: 'web-alerts-1194', appId: '1:370456186282:web:a1818e52c9bb508cf2efd3', databaseURL: 'https://web-alerts-1194.firebaseio.com/', storageBucket: 'gcm-demo-13f40.appspot.com', messagingSenderId: '370456186282' }); const messaging = getMessaging(firebaseApp); experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging, true); const showNotification = function(title, notification) { return self.registration.showNotification(title, { ...notification, badge: 'https://conteudo.imguol.com.br/c/push-webalert/badge.v4.png', data: { link: notification.click_action } }); }; self.addEventListener('push', function(event) { const payload = event.data.json(); event.waitUntil( showNotification(payload.notification.title, payload.notification) ); }); self.addEventListener('notificationclick', function(event) { event.notification.close(); if(event.notification && event.notification.data && event.notification.data.link) { const notificationPage = event.notification.data.link; event.waitUntil( clients.openWindow(notificationPage) ); } }); self.AreaStorage.push({ config: { cacheName: '[VUELAND][ASSETS][SVG]', strategy: 'CacheFirst', plugins: { expiration: { maxEntries: 10, maxAgeSeconds: 518400, purgeOnQuotaError: true } } }, cache: { precache: [], assets: [{url: new RegExp('^https?:\\/\\/c.jsuol.com.br\\/assets\\/(.*)&loadSvgs\\=')}] } }); self.AreaStorage.push({ config: { cacheName: '[VUELAND][SERVICES]', strategy: 'StaleWhileRevalidate', plugins: { expiration: { maxEntries: 10, maxAgeSeconds: 604800, purgeOnQuotaError: true } } }, cache: { precache: [], assets: [{url: new RegExp('^https?:\\/\\/c.jsuol.com.br\\/assets\\/(.*)loadComponent\\=JupiterTeamShowcase')}] } }); self.AreaStorage.push({ config: { cacheName: '[VUELAND][ASSETS][CSS]', strategy: 'StaleWhileRevalidate', plugins: { expiration: { maxEntries: 100, maxAgeSeconds: 518400, purgeOnQuotaError: true } } }, cache: { precache: [], assets: [ {url: new RegExp('^https?:\\/\\/c.jsuol.com.br\\/assets\\/(.*)loadComponent\\=Media&contentType\\=css&scope\\=assets')} ] } });