Badges

Notification Badges that show on app icons

Badges generally refer to the little numbered dots that show up on your mobile app icon and are meant to help capture a response from the user.

Web Push badges are the small icon shown on android web notifications and can be customized.

Android Badges

The OneSignal SDK automatically sets the badge count on your app to the number of notifications that are currently in the notification shade. If you want to disable this you can do the following...

For Android 8+ you can turn off the badges from showing using Notification Categories. The notification dot was added in Android Oreo (8.0) but a badge number may still be showing instead if the device is using an Android Launcher that uses the non-standardized badge number.

Pre Android 8 will need to follow this guide below and set the badges manually.

Disable Badges for Pre Android 8 Devices

This guide is only for Android 7 and lower. If you only want to support Android 8+ use Notification Categories.

Add the following to your AndroidManifest.xml

<application ...>
   <meta-data android:name="com.onesignal.BadgeCount" android:value="DISABLE" />
</application>

You can remove the badge permissions with the following entries.

<uses-permission android:name="com.sec.android.provider.badge.permission.READ" tools:node="remove" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" tools:node="remove" />
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" tools:node="remove" />
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT" tools:node="remove" />
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" tools:node="remove" />
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE" tools:node="remove" />
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT" tools:node="remove" />
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE" tools:node="remove" />
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" tools:node="remove"/>
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" tools:node="remove" />
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" tools:node="remove" />
<uses-permission android:name="android.permission.READ_APP_BADGE" tools:node="remove" />
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS" tools:node="remove" />
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS" tools:node="remove" />

You will also need to add the the following to your manifest tag at the top of the file.
xmlns:tools="http://schemas.android.com/tools"

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="com.onesignal.example">
          ...
</manifest>

You can now set badges manually with a library like https://github.com/leolin310148/ShortcutBadger

🚧

Note: Android badges are only supported by our latest SDK and only on the following Android Launchers: Sony, Samsung, LG, HTC, Xiaomi, Huawei, ASUS, ZUK, OPPO, ADW, APEX, and NOVA. More details here.


iOS Badges

You must setup the App Groups feature as outlined in our Mobile Push setup guide you used to add OneSignal to your app.

Send Push with Badges - iOS

Sending from the API, use the ios_badgeType and ios_badgeCount properties.

When Sending Push Messages from the Dashboard, under Platform Settings > Send to Apple iOS, use either "Set to" or "Increase by" and enter a number.

870

iOS Badge Behavior

The badge icon number is cleared automatically when the app is resumed or opened. Setting the count to 0 with a notification will also clear the value.

If you want to prevent our SDK from automatically clearing badges set OneSignal_disable_badge_clearing to YES as a Boolean type in your .plist in Xcode.

2274

​Setting YES will stop badges from clearing when removing notifications from the notification center or clicking the app to open it. You can manually updated badges using the Native iOS Badge Handling methods. Or the "Set to" property when sending notifications from the Dashboard or API.

Set OneSignal_disable_badge_clearing to NO as a Boolean type to enable OneSignal badge clearing.

iOS Badges Troubleshooting

If you are seeing incorrect badge counts, see our iOS SDK App Groups setup to make sure you have this setup. For further troubleshooting, see iOS App Group Troubleshooting.