File name
Commit message
Commit date
self.addEventListener("install", function (e) {
console.log("fcm sw install..");
self.skipWaiting();
});
self.addEventListener("activate", function (e) {
console.log("fcm sw activate..");
});
/* self.addEventListener("push", function (e) {
console.log("push: ", e.data.json());
if (!e.data.json()) return;
const resultData = e.data.json().notification;
const notificationTitle = resultData.title;
const notificationOptions = {
body: resultData.body,
icon: resultData.image,
tag: resultData.tag,
...resultData,
};
console.log("push: ", { resultData, notificationTitle, notificationOptions });
self.registration.showNotification(notificationTitle, notificationOptions);
}); */
self.addEventListener("push", function (e) {
console.log("push: ", e.data.json());
if (!e.data.json()) return;
const resultData = e.data.json();
//console.log("push resultData : ", resultData);
const notificationTitle = resultData.notification.title;
const notificationOptions = {
body: resultData.notification.body,
icon: resultData.notification.image, // 웹 푸시 이미지는 icon
tag: resultData.notification.tag,
data: resultData.data
};
self.registration.showNotification(notificationTitle, notificationOptions);
});
self.addEventListener("notificationclick", function (event) {
console.log("notification click event.notification : ", event.notification);
const url = "/";
event.notification.close();
event.waitUntil(clients.openWindow(url));
});