Skip to content

Commit

Permalink
Merge pull request #472 from woowacourse-teams/feat/#470
Browse files Browse the repository at this point in the history
알림 카드 클릭 시, url이동하는 기능 수정, 알림 2번 오는 기능 수정
  • Loading branch information
jaeml06 authored Aug 22, 2024
2 parents c609948 + af08a53 commit 921779b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 0 additions & 9 deletions frontend/public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,4 @@ const messaging = firebase.messaging();

messaging.onBackgroundMessage((payload) => {
console.log('[firebase-messaging-sw.js] 백그라운드 메시지 수신:', payload);

const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
data: {
click_action: payload.fcmOptions.link, // 이 필드는 밑의 클릭 이벤트 처리에 사용됨
},
};
self.registration.showNotification(notificationTitle, notificationOptions);
});
6 changes: 4 additions & 2 deletions frontend/src/components/NotificationList/NotificationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import NotificationCard from '@_components/NotificationCard/NotificationCard';
import { Notification } from '@_types/index';
import * as S from '@_components/NotificationList/NotificationList.style';
import { useNavigate } from 'react-router-dom';
import { removeBaseUrl } from '@_utils/formatters';

interface NotificationListProps {
notifications: Notification[];
Expand All @@ -11,8 +10,11 @@ export default function NotificationList(props: NotificationListProps) {
const { notifications } = props;
const navigate = useNavigate();
const handleClickNotificationCard = (url: string) => {
navigate(removeBaseUrl(url));
const parsedUrl = new URL(url);
const relativePath = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;
navigate(relativePath);
};

return (
<div css={S.cardListSection}>
{notifications.map((notification, index) => {
Expand Down

0 comments on commit 921779b

Please sign in to comment.