-
Notifications
You must be signed in to change notification settings - Fork 2
/
fcm-sw.js
33 lines (29 loc) · 1.06 KB
/
fcm-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
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js');
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
messagingSenderId: '1065550303539'
});
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.
// [START background_handler]
messaging.setBackgroundMessageHandler(function(payload) {
console.log(
'[firebase-messaging-sw.js] Received background message ',
payload
);
// Customize notification here
var notificationTitle = 'Lit-Element';
var notificationOptions = {
body: 'Lit-Element is awesome',
icon: '/src/images/manifest/icon-96x96.png'
};
return self.registration.showNotification(
notificationTitle,
notificationOptions
);
});
// [END background_handler]