1

I am creating a chat application, where I need to send notifications when the user is not watching my website or working in another application.

Now, most of the use cases can be handled using the page visibility API. But there is a particular use case when the user is switching the application from browser to any other application(ex: Outlook), I want to send a notification at that time.

But the issue here is page visibility API does not provide anything on switching applications. That is if the browser active tab has my website and the user switches the application from browser to any other application, it still thinks the user is looking at my website which is wrong because the user is in anther application right now.

I have done R&D on this and I see it is impossible because browsers can't detect these kinds of changes due to security reasons.

But when I checked with Whatsapp web there, javascript is able to find weather user opened the current application or not and based on that they are sending notifications.

So, How can I implement same feature that Whatsapp guys implemented? Is there any web API I am missing here. Are any hacks available to implement this kind feature?

Thanks in advance.

Vijay
  • 99
  • 4
  • 16

0 Answers0