Skip to content

Commit

Permalink
fix: 서비스 워커 관련 이슈 해결 (#159)
Browse files Browse the repository at this point in the history
* chore: 애셋 폴더 정리 및 개발 서버에서 PWA 워커 실행 안함

* feat: 푸쉬 이벤트를 수신하는 서비스 워커 작성

* chore: menifest 관련 추가 설정
  • Loading branch information
bbearcookie authored Nov 17, 2023
1 parent f17c7b3 commit 5768a3d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 5 deletions.
31 changes: 31 additions & 0 deletions public/firebase-messaging-sw.js
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
15 changes: 10 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,36 @@ export default defineConfig({
VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
strategies: 'injectManifest',
filename: 'firebase-messaging-sw.js',
devOptions: {
enabled: true,
enabled: false,
type: 'module'
},
manifest: {
name: 'Moabam: 당신의 루틴을 지켜요!',
short_name: 'Moabam',
description: '성취감과 의무감을 더하는 루틴 관리 웹 앱',
theme_color: '#60D4DE',
icons: [
{
src: 'pwa-64x64.png',
src: 'pwa/pwa-64x64.png',
sizes: '64x64',
type: 'image/png'
},
{
src: 'pwa-192x192.png',
src: 'pwa/pwa-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'pwa-512x512.png',
src: 'pwa/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any'
},
{
src: 'maskable-icon-512x512.png',
src: 'pwa/maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
Expand Down

0 comments on commit 5768a3d

Please sign in to comment.