cordova-plugin-badge
Cordova plugin to access and modify the badge number of the app icon on various mobile platforms including iOS, Android and Windows.
Supported Platforms
Android / Amazon FireOS (via ShortcutBadger)
Browser (via favico.js)
iOS 10+
OSX
Windows (Phone and Desktop)
Installation
The plugin can be installed via Cordova-CLI and is publicly available on NPM.
Execute from the projects root folder:
$ cordova plugin add cordova-plugin-badge
Or install a specific version:
$ cordova plugin add cordova-plugin-badge@VERSION
Or install the latest head version:
$ cordova plugin add https://github.com/katzer/cordova-plugin-badge.git
Or install from local source:
$ cordova plugin add <path> --nofetch --nosave
Usage
The plugin creates the object cordova.plugins.notification.badge and is accessible after deviceready has been fired.
document.addEventListener('deviceready', function () {
// cordova.plugins.notification.badge is now available
}, false);
Set the badge number
Badge numbers cannot be negative. The maximum might be restricted by the OS. A callback is optional and will be invoked with the current badge number.