Search code examples
macosgoogle-chromepush-notificationweb-push

Web Push Notifications not appearing when tab closed


My chrome push notifications work when the browser tab is open but not when it is closed. From what I understand the notification should appear even when the tab is closed.

I have verified that the notifications are allowed for the site

enter image description here

How can I debug why push notifications are not working when the tab is closed?

Btw I am on a mac.


Solution

  • You are confusing two different technologies:

    • using the Notification API alone, as you do, will show the notification only when the page is open
    • in order to show notifications when a website is closed you need to use Service Workers + Push API + Notification API as I described in this answer