Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Cordova badge plugin for access and modify badge numbers

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.35k
    Comment on it

    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);
    });

     

    • Set the badge number:
    cordova.plugins.notification.badge.set(10);
    • Clear the badge number:
    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: