Notification Badges
Control Notification Badge Counts
Overview
Push notification badge counts help users quickly identify the number of unread messages or alerts in your app. This guide explains how to set and clear badge counts using the Median JavaScript SDK with OneSignal integration, including platform-specific considerations for iOS and Android.
Legacy Support
This method is not available on the legacy OneSignal plugin. To learn more about it see Legacy Mode
Badge Count Behavior on iOS and Android
- iOS: Badge counts appear as a small number overlay on the top-right corner of your app icon. This is natively supported on iOS devices.
- Android: Badge count support depends on the device manufacturer (OEM). Some Android devices may not display badge counts unless explicitly supported.
For full documentation on badge support and platform differences, refer to the official OneSignal Badged Documentation.
Implementation Guide
To manually set or clear badge counts using the Median JavaScript Bridge, use the following code snippet:
↔️Median JavaScript Bridge
// Set the badge count to 2 median.onesignal.badge.set(2); // Clear the badge count median.onesignal.badge.set(0);
Frequently Asked Questions
How Do I Clear the Push Notification Badge Count on iOS?
To enable OneSignal to reset badge counts on iOS, you must configure App Groups for both your app and the OneSignal Notification Service Extension.
Required Steps:
- Enable the App Groups capability for both:
- Your Main App Target
- The OneSignalNotificationServiceExtension Target
- Set the App Group container identifier to:
-
Replacegroup.YOUR_BUNDLE_IDENTIFIER.onesignal
YOUR_BUNDLE_IDENTIFIER
with the actual Bundle Identifier of your main application.
-
For a step-by-step tutorial with screenshots, refer to OneSignal’s official documentation: Add App Groups on iOS.
Updated about 1 month ago