-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirebase-messaging-sw.js
39 lines (33 loc) · 1.15 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
36
37
38
39
importScripts('https://www.gstatic.com/firebasejs/4.3.0/firebase-app.js');
importScripts('firebase-messaging.js');
var config = {
apiKey: "AIzaSyCFXQqvJGGpcNeSittYro6zy5e03itmDLg",
authDomain: "ideainnovationcell.firebaseapp.com",
databaseURL: "https://ideainnovationcell.firebaseio.com",
projectId: "ideainnovationcell",
storageBucket: "ideainnovationcell.appspot.com",
messagingSenderId: "368936158980",
appId: "1:368936158980:web:14751bb19594425bfcb251",
measurementId: "G-4E9R4VDDRL"
};
firebase.initializeApp(config);
const messaging= firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload){
const title='Idea Innovation Cell';
const options={
body: payload.data.message,
icon: payload.data.icon,
image:payload.data.image,
data:{
click_action: payload.data.click_action
}
};
return self.registration.showNotification(title,options);
});
self.addEventListener('notificationclick', function(event){
var action_click=event.notification.data.click_action;
event.notification.close();
event.waitUntil(
clients.openWindow(action_click)
);
});