Hello Readers,
Cordova badge plugin notify users to that there is something for them when app is in background. For example: Unread messages, Notifications in apps, etc.
This plugin works on Android, iOS, Windows, Wp8, Wp8.1 platforms and allows you to increase, clear, set and get badge number.
First of all we need to install the plugin via CLI :
$ cordova plugin add https://github.com/katzer/cordova-plugin-badge.git
Now take a look the plugin and its methods. plugin and its methods will not available before the device ready event has been fired. This plugin creates an object cordova.plugins.notifications.badge with some methods which are as follows:
- Determine permission to set badge notifications:
cordova.plugins.notification.badge.hasPermission(function (granted) {
console.log('Permission has been granted: ' + granted);
});
- Register permission to set badge notifications:
cordova.plugins.notification.badge.registerPermission(function (granted) {
console.log('Permission has been granted: ' + granted);
});
cordova.plugins.notification.badge.set(10);
cordova.plugins.notification.badge.clear();
- Increase the badge number:
cordova.plugins.notification.badge.increase();
- Decrease the badge number:
cordova.plugins.notification.badge.decrease(2);
Hope this will help you :)
0 Comment(s)