User Agents

Web browsers and everyday web tech, explained

Chrome PWA Notification Badges: How to Enable and Use

· 5 min read · Settings and Privacy

In this article
  1. Understanding the App Badging API
  2. Technical Implementation Steps
  3. OS Compatibility and Behavior
  4. Common Implementation Problems
  5. Comparing Badges to Push Notifications
  6. Safety and User Experience Best Practices
  7. Frequently Asked Questions

To enable notification badges on a Chrome Progressive Web App (PWA), developers must implement the App Badging API using the navigator.setAppBadge() method. For the user, the PWA must be installed on the device, and the operating system must support app badges (such as macOS, Windows, or Android) for the badge to appear on the app icon.

Understanding the App Badging API

The App Badging API is a specialized web interface that allows a PWA to display a small visual indicator—typically a red dot or a number—on the application's icon. This is designed to alert users to pending notifications, unread messages, or updates without requiring the app to be open in the foreground. Unlike standard push notifications, which are transient banners, a badge is a persistent state indicator.

Historically, this functionality was reserved for native applications. By exposing this to PWAs, Chrome allows web apps to achieve a level of integration with the OS that mimics a native experience, increasing user engagement and retention. It is important to note that the badge is not a notification itself, but a signal that a notification exists within the app.

Technical Implementation Steps

Implementing badges requires a combination of client-side JavaScript and, typically, a Service Worker to handle background updates. Here is the standard process for enabling them:

  1. Check for Browser Support: Before calling the API, the code should verify if navigator.setAppBadge exists to avoid errors in unsupported browsers.
  2. Setting the Badge: To display a badge, the developer calls navigator.setAppBadge(count). If the count is a positive integer, some operating systems will display that specific number. If the count is omitted or set to a generic value, a simple dot is often shown.
  3. Clearing the Badge: Once the user has viewed the notifications, the badge must be removed. This is done by calling navigator.clearAppBadge().
  4. Background Updates: To update the badge while the app is closed, the logic is placed inside a Service Worker. When a push notification is received via the Push API, the Service Worker triggers the setAppBadge method to update the icon in real-time.

OS Compatibility and Behavior

The appearance and behavior of notification badges vary significantly depending on the platform where the Chrome PWA is installed:

  • Windows: Badges typically appear as a small overlay on the taskbar icon. Windows supports both numeric counts and generic dots.
  • macOS: Badges appear on the Dock icon. macOS is highly supportive of numeric badges, which is a primary way users track unread emails or messages.
  • Android: Support varies by manufacturer and launcher. Many Android devices show a dot on the app icon in the app drawer or home screen, though numeric badges are less consistent across different OEM skins.
  • ChromeOS: As the native OS for Chrome, ChromeOS provides robust support for PWA badges on the shelf.

Common Implementation Problems

Developers often encounter several hurdles when trying to get badges to appear. One of the most common is the Installation Requirement. Badges will not work if the user is simply visiting the website in a browser tab; the site must be "installed" as a PWA (added to home screen or installed via the Chrome address bar) to have an icon that can actually hold a badge.

Another common issue is Permission Conflicts. While the Badging API itself does not require a specific "Badge Permission" prompt like the Camera or Microphone APIs, it is closely tied to the Push API. If a user has blocked notifications for the site, the Service Worker may be unable to trigger badge updates in the background, effectively disabling the feature.

Finally, there is the issue of State Synchronization. If a user clears notifications on a desktop PWA, the badge on their mobile PWA may remain unless the server sends a specific signal to clear the badge across all registered devices.

Comparing Badges to Push Notifications

It is a common misconception that badges replace push notifications. In reality, they serve complementary purposes. A push notification is an active alert—it pops up, makes a sound, and demands immediate attention. A badge is a passive alert—it informs the user that something is waiting for them whenever they happen to look at their app list.

Using only push notifications can lead to "notification fatigue," where users disable alerts because they are too intrusive. Integrating badges allows developers to be less aggressive with pop-ups while still ensuring the user doesn't forget to check the app for important updates.

Safety and User Experience Best Practices

To maintain a positive user experience and avoid being flagged as spammy, developers should follow these guidelines:

  • Avoid Badge Inflation: Do not set the badge count to an absurdly high number (e.g., 999+) for trivial updates, as this can annoy users.
  • Immediate Clearance: Ensure the badge is cleared the moment the user navigates to the relevant section of the app. A badge that persists after the content has been read is perceived as a bug.
  • Contextual Relevance: Only use badges for information that provides genuine value, such as a direct message or a critical system alert, rather than generic marketing prompts.

Frequently Asked Questions

Why is my PWA badge not showing on Android?

This is often due to the specific Android launcher or OS skin (like Samsung One UI or Xiaomi MIUI) used on the device. Some launchers disable notification dots by default in the system settings, or they only support dots rather than numbers. Check the system's "Notifications" settings to ensure "Notification dots on app icons" is enabled.

Do I need a special plugin for Chrome PWA badges?

No, the App Badging API is built directly into the Chromium engine. As long as you are using a modern version of Chrome or an Edge browser, the functionality is available via standard JavaScript without any external libraries or plugins.

Can I set a custom color for the notification badge?

No. The visual style of the badge, including its color and shape, is determined by the operating system (Windows, macOS, Android), not the web developer. This ensures a consistent look and feel across all applications on the user's device.

Will badges work in Incognito mode?

No. PWAs must be installed to display badges, and installation is not supported in Incognito mode. Additionally, Service Workers, which are required for background badge updates, do not persist in the same way within private browsing sessions.

Does the user have to grant permission for badges?

The App Badging API itself does not trigger a permission prompt. However, because badges are almost always triggered by push events, the user must grant permission for the PWA to send "Notifications" for the background update logic to function.