Skip to main content

Badge

EOL Notice

Badge will reach its end-of-life on July 1, 2024, and will no longer receive updates or support. Please see Support Policy for additional information.

The Badge plugin enables an application to inform its users that it has something for them — for example, unread messages — when the application isn’t running in the foreground.

Android Note: Badges have historically only been a feature implemented by third party launchers and not visible unless one of those launchers was being used (E.G. Samsung or Nova Launcher) and if enabled by the user. As of Android 8 (Oreo), notification badges were introduced officially to reflect unread notifications. This plugin is unlikely to work as expected on devices running Android 8 or newer. Please see the local notifications plugin docs for more information on badge use with notifications.

Installation

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/badge
npx cap sync

Index

Classes


Classes

Badge

Badge:

usage:

import { Badge } from '@ionic-enterprise/badge/ngx';

constructor(private badge: Badge) { }

...

this.badge.set(10);
this.badge.increase(1);
this.badge.clear();

clear

clear(): Promise<boolean>

Clear the badge of the app icon.

Returns: Promise<boolean>


decrease

decrease(decreaseBy: number): Promise<any>

Decrease the badge number.

Parameters:

NameTypeDescription
decreaseBynumberCount to subtract from the current badge number

Returns: Promise<any>


get

get(): Promise<any>

Get the badge of the app icon.

Returns: Promise<any>


hasPermission

hasPermission(): Promise<any>

Determine if the app has permission to show badges.

Returns: Promise<any>


increase

increase(increaseBy: number): Promise<any>

Increase the badge number.

Parameters:

NameTypeDescription
increaseBynumberCount to add to the current badge number

Returns: Promise<any>


isSupported

isSupported(): Promise<any>

Check support to show badges.

Returns: Promise<any>


requestPermission

requestPermission(): Promise<any>

Register permission to set badge notifications

Returns: Promise<any>


set

set(badgeNumber: number): Promise<any>

Set the badge of the app icon.

Parameters:

NameTypeDescription
badgeNumbernumberThe new badge number.

Returns: Promise<any>