Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Optimization That Was Too Good: Why Our Push Notifications Only Worked When You Weren't Looking

This is a submission for DEV's Summer Bug Smash: Smash Stories powered by Sentry . When I was building the push notification system for ShelfTalk — a real-time social app that won the GitHub Finish Up A Thon Challenge on DEV — I wanted to be considerate of my users. There's nothing more annoying than actively chatting in a web app and having your desktop ping you with a notification for the exact…

The push notification system for ShelfTalk, a real-time social app, accidentally functioned optimally only when users weren't actively using the app. The developer, JaniDhruv, implemented a brilliant optimization to prevent desktop notifications from appearing while a user was actively reading a message. However, this optimization failed to account for scenarios where the ShelfTalk tab remained visible on a second monitor, even when the user was working on another application.

Consequently, important notifications, such as direct messages and group mentions, were being missed by users who had the ShelfTalk app open on a secondary monitor while focusing on other tasks. The issue arose because the Page Visibility API (document.hidden) only returned true when the page was completely hidden, either behind other windows or minimized.

If the tab was visible on a second monitor, document.hidden was false, and the notification still fired. Users left on their main screen were completely unaware of the missed notifications, and even users at home working on another device would miss messages if their office machine was still actively looking at the ShelfTalk app.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Understanding OAuth2 the Simple Way

Understanding OAuth2 the Simple Way You are building a side project and want users to log in with their Google accounts instead of making up yet another password they'll forget.

  • OAuth2 enables Google login without new passwords
  • Simplified as handing a digital valet key for specific actions
  • Authorization Code Flow involves four steps for web apps

More from Saturday 22 August →