Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

receive notifications on new message #23

Open
andremarretto opened this issue May 12, 2023 · 2 comments
Open

receive notifications on new message #23

andremarretto opened this issue May 12, 2023 · 2 comments

Comments

@andremarretto
Copy link

Hi,

How can I get a notification when I receive a new message,
there´s a way to activate this feat.?

@andremarretto andremarretto changed the title receive notifications on news messages receive notifications on new messages May 12, 2023
@andremarretto andremarretto changed the title receive notifications on new messages receive notifications on new message May 12, 2023
@andremarretto
Copy link
Author

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
Copy link

krabhi1 commented Jul 4, 2023

we can use web push API
check this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants