Skip to content

Commit

Permalink
chore: 테스트용
Browse files Browse the repository at this point in the history
  • Loading branch information
im-na0 committed Jan 27, 2024
1 parent 7e3f680 commit 22cc194
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
44 changes: 27 additions & 17 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ self.importScripts(
"https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js",
);

var firebaseConfig = {
apiKey: "AIzaSyAc4XrxZs2G1EVp-NbpCh5rw9rVgnUG284",
authDomain: "scbj-af2e3.firebaseapp.com",
projectId: "scbj-af2e3",
storageBucket: "scbj-af2e3.appspot.com",
messagingSenderId: "177564796245",
appId: "1:177564796245:web:6b27b878cbc2ccacf39bdc",
measurementId: "G-1YD7ZEM9HM",
};

firebase.initializeApp(firebaseConfig);

// // Retrieve an instance of Firebase Messaging so that it can handle background
// // messages.
// const messaging = firebase.messaging();
const messaging = firebase.messaging();

self.addEventListener("install", function () {
console.log("fcm sw install..");
Expand All @@ -33,13 +45,14 @@ self.addEventListener("push", function (e) {
console.log("push: ", e.data.json());
if (!e.data.json()) return;

const resultData = e.data.json().notification;
console.log("디버깅용", e.data.json().notification);

const resultData = e.data.json().data;
const notificationTitle = resultData.title;
const notificationOptions = {
body: resultData.body,
body: resultData.message,
icon: resultData.image,
tag: resultData.tag,
...resultData,
};
console.log("push: ", { resultData, notificationTitle, notificationOptions });

Expand All @@ -53,17 +66,14 @@ self.addEventListener("notificationclick", function (event) {
event.waitUntil(self.clients.openWindow(url));
});

// messaging.onBackgroundMessage(function (payload) {
// console.log(
// "[firebase-messaging-sw.js] Received background message ",
// payload,
// );
// // Customize notification here
// const notificationTitle = "Background Message Title";
// const notificationOptions = {
// body: "Background Message body.",
// icon: "/firebase-logo.png",
// };
messaging.onBackgroundMessage(function (payload) {
console.log("Received background message", payload);
// Customize notification here
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: "/icon-192.png",
};

// self.registration.showNotification(notificationTitle, notificationOptions);
// });
self.registration.showNotification(notificationTitle, notificationOptions);
});
1 change: 0 additions & 1 deletion src/components/A2HS/A2HS.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,5 @@ export const DismissButton = styled(Button)`
&:hover {
background-color: ${({ theme }) => theme.color.greyScale7};
border-radius: 50%;
}
`;
5 changes: 5 additions & 0 deletions src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import Header from "./header/HeaderTop";
import * as S from "./Layout.style";
import BottomNav from "./navBottom/NavBottom";
import A2HS from "../A2HS/A2HS";
import { useLocation } from "react-router-dom";
import { PATH } from "@/constants/path";
interface ChildrenProps {
children: React.ReactNode;
isHeaderOn: boolean;
isBottomNavOn: boolean;
}

const Layout = ({ children, isHeaderOn, isBottomNavOn }: ChildrenProps) => {
const { pathname } = useLocation();

return (
<S.Container>
<S.Wrapper>
{isHeaderOn && <Header />}
<A2HS />
{children}
{pathname === PATH.ROOT && <A2HS />}
{isBottomNavOn && <BottomNav />}
</S.Wrapper>
</S.Container>
Expand Down

0 comments on commit 22cc194

Please sign in to comment.