PageSourceSearch

https://cricketlive11.com/firebase-messaging-sw.js

js cricketlive11.com collected 2026-10-02 01:27:55 UTC 3,059 bytes, 99 lines download raw bytes

1// Firebase Cloud Messaging Service Worker
2importScripts('https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js');
3importScripts('https://www.gstatic.com/firebasejs/9.22.0/firebase-messaging-compat.js');
4
5// Firebase configuration - Production config
6const firebaseConfig = {
7  apiKey: "AIzaSyCuqRhEHK_dptAIBSfs5U8B5zfOVmfhQvg",
8  authDomain: "cricchat-3b7e7.firebaseapp.com",
9  projectId: "cricchat-3b7e7",
10  storageBucket: "cricchat-3b7e7.firebasestorage.app",
11  messagingSenderId: "360276141027",
12  appId: "1:360276141027:web:eb64e48f51d9a564acb6d6",
13  measurementId: "G-RHWLL8QYVG"
14};
15
16// Initialize Firebase
17firebase.initializeApp(firebaseConfig);
18
19// Initialize Firebase Cloud Messaging
20const messaging = firebase.messaging();
21
22// Handle background messages
23messaging.onBackgroundMessage((payload) => {
24  console.log('Received background message:', payload);
25
26  const notificationTitle = payload.notification?.title || payload.data?.title || 'CricketLive11';
27  const notificationOptions = {
28    body: payload.notification?.body || payload.data?.body || 'New cricket update!',
29    icon: '/icons/icon-192x192.png',
30    badge: '/icons/icon-72x72.png',
31    tag: payload.data?.tag || 'cricket-notification',
32    requireInteraction: true,
33    data: payload.data,
34    actions: [
35      {
36        action: 'view',
37        title: 'View'
38      },
39      {
40        action: 'dismiss',
41        title: 'Dismiss'
42      }
43    ]
44  };
45
46  // Add image if available
47  if (payload.notification?.image || payload.data?.image) {
48    notificationOptions.image = payload.notification?.image || payload.data?.image;
49  }
50
51  // Show notification
52  return self.registration.showNotification(notificationTitle, notificationOptions);
53});
54
55// Handle notification click
56self.addEventListener('notificationclick', (event) => {
57  console.log('Notification click received:', event);
58
59  event.notification.close();
60
61  // Handle action clicks
62  if (event.action === 'dismiss') {
63    return;
64  }
65
66  // Default action or 'view' action
67  const urlToOpen = event.notification.data?.route || '/';
68
69  event.waitUntil(
70    clients.matchAll({ type: 'window', includeUncontrolled: true })
71      .then((windowClients) => {
72        // Check if there is already a window/tab open with the target URL
73        for (let client of windowClients) {
74          if (client.url === urlToOpen && 'focus' in client) {
75            return client.focus();
76          }
77        }
78
79        // If not, open a new window/tab with the target URL
80        if (clients.openWindow) {
81          return clients.openWindow(urlToOpen);
82        }
83      })
84  );
85});
86
87// Handle service worker installation
88self.addEventListener('install', (event) => {
89  console.log('Service worker installing...');
90  // Skip waiting to activate the new service worker immediately
91  self.skipWaiting();
92});
93
94// Handle service worker activation
95self.addEventListener('activate', (event) => {
96  console.log('Service worker activating...');
97  // Claim all clients to start controlling them immediately
98  event.waitUntil(self.clients.claim());
99});

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.