This commit is contained in:
tamaina
2021-02-13 01:28:20 +09:00
parent 538bba080f
commit 979f91bd34
5 changed files with 138 additions and 35 deletions

View File

@@ -58,9 +58,11 @@ self.addEventListener('push', ev => {
const data: pushNotificationData = ev.data?.json();
console.log('push', data)
switch (data.type) {
case 'notification':
// case 'driveFileCreated':
case 'notification':
case 'unreadMessagingMessage':
return createNotification(data);
case 'readAllNotifications':
@@ -83,6 +85,7 @@ self.addEventListener('push', ev => {
//#region Notification
self.addEventListener('notificationclick', ev => {
const { action, notification } = ev;
console.log('click', action, notification)
const data: pushNotificationData = notification.data;
const { origin } = location;
@@ -110,6 +113,8 @@ self.addEventListener('notificationclick', ev => {
self.addEventListener('notificationclose', ev => {
const { notification } = ev;
console.log('close', notification)
if (notification.title !== 'notificationclose') {
self.registration.showNotification('notificationclose', { body: `${notification?.data?.body?.id}` });
}