Skip to content

Push notifications: suppress when user is actively using the app (tab visible / online) #176

Description

@serge-ivo

Bug

Push notifications are being sent even when the user is actively looking at the app. If the user has the app open and visible (tab is in the foreground, app is online), push notifications should be suppressed entirely — they are redundant and disruptive.

Expected behavior

  • Push notifications should only be delivered when the user is not looking at the app — i.e., the tab/window is hidden, the app is in the background, or the client has gone offline.
  • If the user is online and the app tab is visible (document.visibilityState === 'visible'), do not send or display a push notification.

Steps to reproduce

  1. Open the app and keep it in the foreground.
  2. Trigger any action that generates a push notification (e.g., agent reply, alert).
  3. Observe that the push notification fires even though the user is actively viewing the app.

Fix

  • On the client side: before registering or displaying a push notification, check document.visibilityState and the online status. If the page is visible and online, suppress the notification.
  • On the service worker / backend side: consider passing a presence/visibility signal so the server can skip sending the push payload when the client is known to be active.
  • Gate the push delivery on: document.visibilityState !== 'visible' || !navigator.onLine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions