chat-app-react-nodejs
chat-app-react-nodejs copied to clipboard
receive notifications on new message
Hi,
How can I get a notification when I receive a new message, there´s a way to activate this feat.?
I´ve tried to use: useEffect(() => { if (socket.current) { socket.current.on('msg-receive', (msg) => { setArrivalMessage({ fromSelf: false, message: msg }); // play notification sound const audio = new Audio('/notification.mp3'); audio.play(); }); } }, []); but It only works if the tab is active
we can use web push API check this link