forked from purplecabbage/phonegap-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Badge.js
executable file
·39 lines (35 loc) · 817 Bytes
/
Badge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* This code is adapted from the work of Michael Nachbaur
* by Simon Madine of The Angry Robot Zombie Factory
* 2010-05-04
* MIT licensed
*
* Converted to Cordova by Joseph Stuhr.
*/
/**
* This class exposes the iPhone 'icon badge' functionality to JavaScript
* to add a number (with a red background) to each icon
* @constructor
*/
function Badge() {
}
/**
* Positive integer sets the badge, 0 or negative clears it
*/
Badge.prototype.set = function(options) {
Cordova.exec("Badge.setBadge", options);
};
/**
* Shorthand to set the badge to 0
*/
Badge.prototype.clear = function() {
Cordova.exec("Badge.setBadge", 0);
};
Cordova.addConstructor(function() {
if(!window.plugins) {
window.plugins = {};
}
if(!window.plugins.badge) {
window.plugins.badge = new Badge();
}
});