SAMPLE APP :point_right:
Cordova plugin to access and modify the badge number of the app icon on various mobile platforms including iOS, Android and Windows.
How they appear to the user
Users see notifications in the following ways:
- Badging the app’s icon
- Progress indicator (OSX based on https://github.com/hokein/DockProgressBar)
- Android / Amazon FireOS (via ShortcutBadger)
- Browser (via favico.js)
- iOS 10+
- Windows (Phone and Desktop)
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
The plugin creates the object
cordova.plugins.notification.badge and is accessible after deviceready has been fired.
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.
There's built-in support to increase the badge number:
To decrease the badge number:
And to clear out the badge number:
Get the badge number
The default value is 0. The badge number wont get lost after reboot or app restart.
Note: Modifying the badge number outside of the plugin does result into wrong behaivor!
To clear the badge number automatically if the user taps the app icon:
OSX supports additional indicators. Other than to
badge these are
The plugin might ask for granting permissions to modify the badge number. That's done automatically but it's also possible to request them manually:
To check if they have been granted already:
On Android not all launchers support badges. In order to set badges the plugin uses ShortcutBadger. Check out their website to see which launchers are supported.
If you're using PhoneGap Build please make sure you specify gradle as your Android build tool in config.xml:
To specify a custom version of ShortcutBadger follow this guide. The name of the property is
# In <your-project>/platforms/android/gradle.propertiesappShortcutBadgerVersion=1.1.22
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
This software is released under the Apache 2.0 License.
Made with 😋 from Leipzig
© 2013 appPlant GmbH