Badge

Improve this doc

The essential purpose of badge numbers is to enable 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.

Requires Cordova plugin: cordova-plugin-badge. For more info, please see the Badge plugin docs.

Repo: https://github.com/katzer/cordova-plugin-badge

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-badge
    $ npm install --save @ionic-native/badge
    
  2. Add this plugin to your app's module

Supported platforms

Usage

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

constructor(private badge: Badge) { }

...

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

Instance Members

clear()

Clear the badge of the app icon.

Returns: Promise<boolean>

set(badgeNumber)

Set the badge of the app icon.

Param Type Details
badgeNumber number

The new badge number.

Returns: Promise<any>

get()

Get the badge of the app icon.

Returns: Promise<any>

increase(increaseBy)

Increase the badge number.

Param Type Details
increaseBy number

Count to add to the current badge number

Returns: Promise<any>

decrease(decreaseBy)

Decrease the badge number.

Param Type Details
decreaseBy number

Count to subtract from the current badge number

Returns: Promise<any>

isSupported()

Check support to show badges.

Returns: Promise<any>

hasPermission()

Determine if the app has permission to show badges.

Returns: Promise<any>

requestPermission()

Register permission to set badge notifications

Returns: Promise<any>

API

Native

General