How to display count of notifications in app launcher icon
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
In modern mobile applications, providing users with a real-time count of notifications has become a common practice. This count often appears as a badge on the app's launcher icon. The implementation of this feature can vary depending on the platform (iOS or Android) and the specific requirements of the application. In this article, we explore how to display the count of notifications on an app launcher icon, discuss the associated technical details, and provide examples to guide developers.
Understanding Notification Counts on App Launcher Icons
Notification counts, commonly known as "badges," are visual indicators that represent unread messages, pending notifications, or any other alert that warrants user attention. They are typically displayed as a small circle containing a number on the app's launcher icon.
Why Use Notification Counts?
- User Engagement: Badges can prompt users to open the app, increasing engagement.
- User Awareness: They ensure critical information is not overlooked.
- Enhanced User Experience: Providing real-time updates on app status.
Implementing Notification Counts
The method of adding a badge to an app launcher icon varies depending on whether you are targeting Android or iOS devices. Below, we explore the implementation for both platforms.
Android
In Android, the capability to display badges is available on devices running certain versions of Android (Oreo 8.0 and later) and is dependent on the launcher. Here are the steps to implement badge counts on Android:
- Add the ShortcutBadger Library:
- Android does not provide direct support for launcher icon badges prior to Oreo. To address this, you can use the ShortcutBadger library, which supports a wide range of launchers:
- Use the library to set the badge count:
- Android 8.0 introduced native badge support.
- You need to request permission from the user to display badges:
- Use the `UIApplication` class to update the badge count:
- Often, you may need to reset badge counts when the app is opened or a notification is read:
- User Permissions: Always ensure you have the user's permission to display badges.
- Consistency: Ensure the badge count is updated consistently across different parts of the app.
- User Experience: Avoid excessive notifications that can overwhelm the user.

