I have react app that plays a sound when receiving a notification. When having many tabs open, the sound plays on all of them which is annoying. I know that there is 2 cases for this:
- When user has multiple tabs open, and one of my app tabs is active.
- When user has multiple different tabs open, and none of my app tabs is active.
The first case can be handled using Page Visibility API
.
But the second case I dont really know how to handle it, any thoughts?
I have seen people talking about handling that with a service worker.