forked from Innovateninjas/Paws-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebase-messaging-sw.js
35 lines (29 loc) · 1.01 KB
/
firebase-messaging-sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* eslint-disable no-undef */
importScripts("https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js");
importScripts(
"https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js"
);
const firebaseConfig = {
apiKey: "AIzaSyBgRI7QrEqlrtj94hZ-MKtYc77XunOc_9w",
authDomain: "paws-b9b64.firebaseapp.com",
projectId: "paws-b9b64",
storageBucket: "paws-b9b64.appspot.com",
messagingSenderId: "610215952536",
appId: "1:610215952536:web:4f832813ef5d58acb010ed",
measurementId: "G-3TBQ0B47KK",
};
firebase.initializeApp(firebaseConfig);
const messaging = firebase.messaging();
messaging.onBackgroundMessage((payload) => {
console.log(
"[firebase-messaging-sw.js] Received background message ",
payload
);
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: "./notification_icon.ico",
};
// eslint-disable-next-line no-restricted-globals
self.registration.showNotification(notificationTitle, notificationOptions);
});