-
Notifications
You must be signed in to change notification settings - Fork 1
/
firebase-messaging-sw.js
34 lines (30 loc) · 1.06 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
importScripts('https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.1/firebase-messaging.js');
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyBLxztEkSVftuyOeKn8Cf1psu9W8sIy7mY",
authDomain: "krypton-web.firebaseapp.com",
projectId: "krypton-web",
storageBucket: "krypton-web.appspot.com",
messagingSenderId: "848117563079",
appId: "1:848117563079:web:67ebee6c2a10c7ef0008e2"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
console.log(
"[firebase-messaging-sw.js] Received background message ",
payload,
);
// Customize notification here
const notificationTitle = payload.data.title;
const notificationOptions = {
body: payload.data.message,
icon: "/assets/img/ic.png",
};
return self.registration.showNotification(
notificationTitle,
notificationOptions,
);
});