-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase-messaging-sw.js
More file actions
31 lines (26 loc) · 1016 Bytes
/
firebase-messaging-sw.js
File metadata and controls
31 lines (26 loc) · 1016 Bytes
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
importScripts("https://www.gstatic.com/firebasejs/7.16.1/firebase-app.js");
importScripts(
"https://www.gstatic.com/firebasejs/7.16.1/firebase-messaging.js",
);
// For an optimal experience using Cloud Messaging, also add the Firebase SDK for Analytics.
importScripts(
"https://www.gstatic.com/firebasejs/7.16.1/firebase-analytics.js",
);
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
messagingSenderId: "276212992139",
apiKey: "AIzaSyBf2X9WgS264j2aFivV03-K_hzD22GpnM4",
projectId: "gdg-strasbourg-vitrine",
appId: "1:276212992139:web:14dfc336202a931c802c8e",
});
// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
const {title, ...options} = JSON.parse(payload.data.notification);
return self.registration.showNotification(
title,
options,
);
});