1// public/firebase-messaging-sw.js 2importScripts('https://www.gstatic.com/firebasejs/9.0.0/firebase-app-compat.js'); 3importScripts('https://www.gstatic.com/firebasejs/9.0.0/firebase-messaging-compat.js'); 4 5firebase.initializeApp({ 6 apiKey: "AIzaSyAIcRM2X8ALB0RUKNgAI-U3JZvxOOYs58U", 7 authDomain: "kerjaholic-project.firebaseapp.com", 8 projectId: "kerjaholic-project", 9 storageBucket: "kerjaholic-project.appspot.com", 10 messagingSenderId: "17773254584", 11 appId: "1:17773254584:web:006f74ef064c384cefa14d", 12 measurementId: "G-6TV25RTBBW" 13}); 14 15const messaging = firebase.messaging(); 16 17// Handle background messages 18messaging.onBackgroundMessage((payload) => { 19 // console.log('Background message received:', payload); 20 21 const notificationTitle = payload.notification?.title || 'New Notification'; 22 const notificationOptions = { 23 body: payload.notification?.body || '', 24 icon: '/icon-192x192.png', // Sesuaikan dengan icon Anda 25 badge: '/badge-72x72.png', 26 tag: payload.data?.tag || 'notification', 27 data: payload.data 28 }; 29 30 self.registration.showNotification(notificationTitle, notificationOptions); 31}); 32 33// Handle notification click 34self.addEventListener('notificationclick', (event) => { 35 // console.log('Notification clicked:', event); 36 event.notification.close(); 37 38 // Navigate to specific URL if provided 39 if (event.notification.data?.url) { 40 event.waitUntil( 41 clients.openWindow(event.notification.data.url) 42 ); 43 } 44});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.