123456789101112131415161718192021 |
- importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js');
- importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js');
- importScripts('config.js');
- firebase.initializeApp(firebaseConfig);
- const messaging = firebase.messaging();
- // If you would like to customize notifications that are received in the
- // background (Web app is closed or not in browser focus) then you should
- // implement this optional method.
- // Keep in mind that FCM will still show notification messages automatically
- // and you should use data messages for custom notifications.
- // For more info see:
- // https://firebase.google.com/docs/cloud-messaging/concept-options
- messaging.onBackgroundMessage(function(payload) {
- console.log('[firebase-messaging-sw.js] Received background message ', payload);
- // Customize notification here
- const notificationTitle = 'We received a message';
- self.registration.showNotification(notificationTitle,payload.notification);
- });
|