I'm currently using the following code to show Desktop notifications in Google Chrome:
new Notification(data.sender.displayName, {
icon: '/images/logo.png',
body: data.content,
});
This is for a chat application and it doesn't make sense to show notifications on the same page as the chat. How can I make it so that the notification only appears when the tab is inactive or if the window is out of focus?
Thanks!