-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: 애셋 폴더 정리 및 개발 서버에서 PWA 워커 실행 안함 * feat: 푸쉬 이벤트를 수신하는 서비스 워커 작성 * chore: menifest 관련 추가 설정
- Loading branch information
1 parent
f17c7b3
commit 5768a3d
Showing
7 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { precacheAndRoute } from 'workbox-precaching'; | ||
|
||
precacheAndRoute(self.__WB_MANIFEST); | ||
|
||
self.addEventListener('install', function (e) { | ||
console.log('[FCM] Service Worker Installed.'); | ||
self.skipWaiting(); | ||
}); | ||
|
||
self.addEventListener('activate', function (e) { | ||
console.log('[FCM] Service Worker Activated.'); | ||
}); | ||
|
||
self.addEventListener('push', function (e) { | ||
const data = e.data.json(); | ||
|
||
if (!data) { | ||
return; | ||
} | ||
|
||
console.log('[FCM] Push Received.'); | ||
|
||
const title = data.notification.title; | ||
|
||
const options = { | ||
icon: data.notification.image, | ||
...data.notification | ||
}; | ||
|
||
self.registration.showNotification(title, options); | ||
}); |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters