Skip to content

Commit

Permalink
feat(FE) : 포그라운드에서 메세지 수신 시 실행할 이벤트 추가 (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
201724554 committed Feb 17, 2023
1 parent 0c97784 commit 914f8fc
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion client/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { setScreenSize } from '@/utils';
import { navigateHome, navigateAuth, navigateMain, initiatePostPage } from '@/pages';
import { routes, navigate } from '@/core/router';

import { initializeApp } from "firebase/app";
import { getMessaging, onMessage } from "firebase/messaging";


routes.push(
{ path: '/', component: navigateHome },
{ path: '/register', component: navigateAuth },
Expand All @@ -13,4 +17,26 @@ routes.push(

const path = window.location.pathname;
navigate(path);
window.addEventListener('resize', setScreenSize);
window.addEventListener('resize', setScreenSize);


const firebaseConfig = {
apiKey: "AIzaSyCsLBsvozvTnYlDH-5cS0A8X_AjV5o4jjM",
authDomain: "amatta-4934f.firebaseapp.com",
projectId: "amatta-4934f",
storageBucket: "amatta-4934f.appspot.com",
messagingSenderId: "196308516589",
appId: "1:196308516589:web:64545440aa5021e8a496e4",
measurementId: "G-4JBCQPF50K"
};

const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);

onMessage(messaging, (payload)=>{
console.log("foreground", payload);
const option = {
body: payload.notification.body
}
return new Notification(payload.notification.title, option);
})

0 comments on commit 914f8fc

Please sign in to comment.