You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Activity
[-]receive notifications on news messages[/-][+]receive notifications on new messages[/+][-]receive notifications on new messages[/-][+]receive notifications on new message[/+]andremarretto commentedon May 15, 2023
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
krabhi1 commentedon Jul 4, 2023
we can use web push API
check this link