- ์๊ตฌ์ฌํญ
์ฐฝ์ด ์ต์ํ๋์ด๋ ๋จ๋ ์๋ฆผ์ด ์์ผ๋ฉด ์ข๊ฒ ๋ค.
-> ๊ธฐ์กด์ snackbar๋ useDialog๋ก ๋์ ๋ ํ์ ์๋ฆผ์ ์ฐฝ์ด ์ต์ํ๊ฐ ๋๋ฉด ๋น์ฐํ ๋ณด์ด์ง ์์.
-> ๋ค๋ฅธ ๋ฉ์๋๊ฐ ํ์
๊ทธ๋์ ์ฐพ์๋ณด๋ค๊ฐ Notification API๋ฅผ ์๊ฒ๋์๋ค.
https://mingule.tistory.com/68
React์์ Browser Notification (ํธ์ ์๋ฆผ) ๊ตฌํํ๊ธฐ
๋ค์ด๊ฐ๊ธฐ Babble ํ๋ก์ ํธ์์ WebSocket์ ํ์ฉํด ์ฑํ ๊ธฐ๋ฅ์ ๊ตฌํํ ๋ฐ ์๋ค. ๊ทธ๋ฐ๋ฐ, ์ ์ ์ ์ฅ์์๋ ๋ด๊ฐ ๋ค์ด๊ฐ ๋ฐฉ์ ์ฑํ ์ด ์๋ก ์ฌ๋ผ์จ์ง, ์ฌ๋ผ์ค์ง ์์์ง ํ์ธํ ๊ธธ์ด ์์๋ค. ๋ฌด์กฐ๊ฑด ๋ค
mingule.tistory.com
https://developer.mozilla.org/ko/docs/Web/API/Notifications_API/Using_the_Notifications_API
์๋ฆผ API ์ฌ์ฉํ๊ธฐ - Web API | MDN
์น ํ์ด์ง๋ ์ฑ์์ ์๋ฆผ(Notifications) API๋ฅผ ์ฌ์ฉํ๋ฉด ํ์ด์ง ์ธ๋ถ์ ํ์๋๋ ์๋ฆผ์ ๋ณด๋ผ ์ ์์ต๋๋ค. ์ด๊ฒ์ ์์คํ ๋ ๋ฒจ์์ ์ฒ๋ฆฌ๋๋ ๊ฒ์ผ๋ก ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ ํด ์ํ๊ฑฐ๋ ๋ฐฑ๊ทธ๋ผ์ด๋์
developer.mozilla.org
์ด๊ฒ๋ ํจ๊ป ์ฐธ๊ณ ํ์๋ค.
๊ถํ ์์ฒญํ๊ธฐ
์ํผ ์๋ฅผ ๋์ฐ๋ ค๋ฉด ์ฐ์ Notification ๊ถํ์ด ์์ด์ผ ํ๋ค. mdn ๋ฌธ์๋ฅผ ๋ด๋ณด๋ฉด ๊ถํ ํ๋ํ๋ ๋ฐฉ๋ฒ์ด ๋์์๋ค.
Notification.requestPermission().then(function (result) {
console.log(result);
});
์ด๊ฑธ ํธ์ถํ๋ฉด ์ URL ์ฐฝ์ชฝ์
์ด๋ฐ์์ผ๋ก ๋ณด์ธ๋ค. ์ ๊ฑธ ๋๋ฌ์ ํ์ฉ์ ํด์ฃผ๋ฉด, ์ฝ์๋ก๊ทธ์ granted๋ผ๊ณ ๋ฌ๋ค.
์๋ฆผ ๋์ฐ๊ธฐ
interface NotificationOptions {
badge?: string;
icon?: string;
}
const notificationRef = useRef<NotificationOptions | null>(null);
const onClickSearch = async () => {
Notification.requestPermission().then(function (result) {
console.log(result);
});
notificationRef.current = new Notification('ใ
ใ
ใ
ใ
', { badge: '', icon: '' });
...์๋ต
}
'Programming > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ React ] JWT ํ ํฐ (0) | 2024.08.22 |
---|---|
[ React ] GET ํธ์ถํ์ง๋ ์์๋๋ฐ ๊ณ์ GET ํธ์ถ๋๋ ํ์ (0) | 2024.08.08 |
[React] ag-grid์์ columnDef์ useMemo์ valueFormatter (0) | 2024.04.03 |
[ AG-GRID ] ๋ณ๊ฒฝ๋ ๋ฐ์ดํฐ๊ฐ ๊ทธ๋ฆฌ๋์ ๋ฐ๋ก ๋ฐ์๋๊ฒ (0) | 2024.03.11 |
[ React ] ์์ด์ฝ ๋๋ฅด๋ฉด ์์ ์ฌ์๋๋ ๊ธฐ๋ฅ (0) | 2024.01.09 |