-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase-messaging-sw.js
More file actions
33 lines (28 loc) · 1.18 KB
/
Copy pathfirebase-messaging-sw.js
File metadata and controls
33 lines (28 loc) · 1.18 KB
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
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js');
const firebaseConfig = {
apiKey: "AIzaSyBPa1xmcpKA5gCaVSC0gelN9YPSRbpB7TY",
authDomain: "test-pushes-744ea.firebaseapp.com",
projectId: "test-pushes-744ea",
storageBucket: "test-pushes-744ea.firebasestorage.app",
messagingSenderId: "364415810958",
appId: "1:364415810958:web:74a40da5bd83183d32b8df",
measurementId: "G-ER37Y39E4E"
};
firebase.initializeApp(firebaseConfig);
const messaging = firebase.messaging();
messaging.onBackgroundMessage((payload) => {
console.log(
'[firebase-messaging-sw.js] Received background message ',
payload
);
console.log("Background message received. ", payload);
let messageElement = $("#message-template").render(payload);
$("#message-container").append(messageElement);
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: '/firebase-logo.png'
};
self.registration.showNotification(notificationTitle, notificationOptions);
});