Ionic Badge


Ionic Badge– We need to install cordova plugin cordova-plugin-badge. Badges are basically used to display some useful information such as new messages even the application is not running in background. Here in this tutorial we are going to explain how you can use ionic Native Badge plugin.


Ionic Badge | Native Badge Plugin Example

First you need to install the cordova plugin cordova-plugin-badge

Installation

You can install this plugin simply as below-

Ionic Native Badge Example:

$ ionic cordova plugin add cordova-plugin-badge
$ npm install --save @ionic-native/badge

Supported Platforms

  • IOS
  • Android
  • Windows
  • Browser

Example

Ionic Native Badge Example:

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 badge icon.
  • set(number) You can set the badge number using this function.
  • get()– Get App Badge Icon.
  • increaseBy(increaseBy)– Increase the badge number.
  • decrease(decreaseBy)– Decrease by number.
  • hasPermission() Check if app has permission to show badges.
  • registerPermission()– Register permission to badges.

Advertisements

Add Comment

📖 Read More