Skip to content

Commit

Permalink
Merge pull request #118 from Ureca-Dangdang-salon/develop
Browse files Browse the repository at this point in the history
알림 테스트 배포
  • Loading branch information
skang9810 authored Dec 11, 2024
2 parents 65f814a + 80f4125 commit fc67ab4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ self.importScripts(
self.importScripts(
'https://www.gstatic.com/firebasejs/9.20.0/firebase-messaging-compat.js'
);

const firebaseConfig = {
apiKey: 'AIzaSyDV1rn-AOUbRKnUrlZTWxs7DRmpLd7ZfY0',
authDomain: 'dangdangsalon-50432.firebaseapp.com',
Expand All @@ -20,15 +19,22 @@ firebase.initializeApp(firebaseConfig);
const messaging = firebase.messaging();

if (!self.firebaseMessagingInitialized) {
self.firebaseMessagingInitialized = true;

messaging.onBackgroundMessage((payload) => {
console.log('Background message received:', payload);
console.log('[Service Worker] Background message received:', payload);

const notificationTitle = payload.notification.title || 'Default Title';
const notificationOptions = {
body: payload.notification.body || 'Default Body',
icon: payload.notification.icon || '/default-icon.png',
};
if (payload.notification) {
const notificationTitle = payload.notification.title || 'Default Title';
const notificationOptions = {
body: payload.notification.body || 'Default Body',
icon: payload.notification.icon || '/default-icon.png',
};

self.registration.showNotification(notificationTitle, notificationOptions);
self.registration.showNotification(
notificationTitle,
notificationOptions
);
}
});
}

0 comments on commit fc67ab4

Please sign in to comment.