<commit_before>Cordova Badge-Plugin
====================

[Cordova][cordova] plugin to access and modify the badge of the app icon.


## Supported Platforms
- **iOS**
- **Android** *(SDK >=11)*<br>
See [Notification Guide][android_notification_guide] for detailed informations and screenshots.
- **WP8**<br>
See [WP8 Guide][wp8_notification_guide] for detailed informations and screenshots.


## Installation
The plugin can either be installed into the local development environment or cloud based through [PhoneGap Build][PGB].

### Adding the Plugin to your project
Through the [Command-line Interface][CLI]:
```bash
# ~~ from master ~~
cordova plugin add https://github.com/katzer/cordova-plugin-badge.git && cordova prepare
```
or to use the last stable version:
```bash
# ~~ stable version ~~
cordova plugin add de.appplant.cordova.plugin.badge && cordova prepare
```

### Removing the Plugin from your project
Through the [Command-line Interface][CLI]:
```bash
cordova plugin rm de.appplant.cordova.plugin.badge
```

### PhoneGap Build
Add the following xml to your config.xml to always use the latest version of this plugin:
```xml
<gap:plugin name="de.appplant.cordova.plugin.badge" />
```
or to use an specific version:
```xml
<gap:plugin name="de.appplant.cordova.plugin.badge" version="0.5.1" />
```
More informations can be found [here][PGB_plugin].


## Using the plugin
The plugin creates the object ```window.plugin.notification.badge``` with the following interface:

### Plugin initialization
The plugin and its methods are not available before the *deviceready* event has been fired.

```javascript
document.addEventListener('deviceready', function () {
    // window.plugin.notification.badge is now available
}, false);
```

### Set the badge of the app icon
The badge of the app can be set through the `notification.badge.set` interface.<br>
The method takes the badge as its argument. It needs to be a number or a string which can be parsed to a number.

#### Further informations
- On Android the badge will be displayed through a notification. See [setTitle][set_title] how to specify a custom notification title.
- On Windows Phone 8 the badge will be displayed through the app's live tile.
- See [get][get] how to get back the current badge of the app icon.
- See [clear][clear] of how to clear the badge of the app icon.
- See the [examples][examples] of how to use the plugin.

```javascript
window.plugin.notification.badge.set(Number);
```

### Get the badge of the app icon
The badge of the app can be accessed through the `notification.badge.get` interface.<br>
The method takes a callback function as its argument which will be called with the badge number. Optional the scope of the callback function ca be defined through a second argument.

```javascript
window.plugin.notification.badge.get( function (badge) {
	// console.log('Badge of the app icon: ' + badge);
}, scope);
```

### Clear the badge of the app icon
The badge of the app can be removed through the `notification.badge.clear` interface.

#### Further informations
- Clearing the badge number is equivalent to set a zero number.
- See [setClearOnTap][set_clear_on_tap] how to clear the badge automatically after the user has taped the app icon.
- See [set][set] of how to set the badge of the app icon.

```javascript
window.plugin.notification.badge.clear();
```

### Clear the badge automatically if the user taps the app icon
The badge of the app can be cleared automatically after the user has taped the app icon through the `notification.badge.setClearOnTap` interface.<br>
The method takes an argument which tells to clear the badge or not. The default value is *false*.

```javascript
window.plugin.notification.badge.setClearOnTap(Boolean);
```


##  Examples
### Set the badge of the app icon
The following example shows how to set the badge of the app icon to **1**.

```javascript
window.plugin.notification.badge.set(1);
// or
window.plugin.notification.badge.set('1');
```

### Clear the badge of the app icon
See below how to clear the badge of the app icon.

```javascript
window.plugin.notification.badge.clear();
// or
window.plugin.notification.badge.set(0);
```

### Clear the badge automatically if the user taps the app icon
```javascript
window.plugin.notification.badge.setClearOnTap(true);
```


## Platform specifics
### Specify custom notification title on Android
The default format for the title is `%d new messages`, but is customizable through `setTitle`.

```javascript
window.plugin.notification.badge.setTitle('%d neue Meldungen');
```

## Quirks
### TypeError: Cannot read property 'currentVersion' of null
The `version.bat` script can to be renamed to `version` as a workaround.<commit_msg>Add missing sentence<commit_after>Cordova Badge-Plugin
====================

[Cordova][cordova] plugin to access and modify the badge of the app icon.


## Supported Platforms
- **iOS**
- **Android** *(SDK >=11)*<br>
See [Notification Guide][android_notification_guide] for detailed informations and screenshots.
- **WP8**<br>
See [WP8 Guide][wp8_notification_guide] for detailed informations and screenshots.


## Installation
The plugin can either be installed into the local development environment or cloud based through [PhoneGap Build][PGB].

### Adding the Plugin to your project
Through the [Command-line Interface][CLI]:
```bash
# ~~ from master ~~
cordova plugin add https://github.com/katzer/cordova-plugin-badge.git && cordova prepare
```
or to use the last stable version:
```bash
# ~~ stable version ~~
cordova plugin add de.appplant.cordova.plugin.badge && cordova prepare
```

### Removing the Plugin from your project
Through the [Command-line Interface][CLI]:
```bash
cordova plugin rm de.appplant.cordova.plugin.badge
```

### PhoneGap Build
Add the following xml to your config.xml to always use the latest version of this plugin:
```xml
<gap:plugin name="de.appplant.cordova.plugin.badge" />
```
or to use an specific version:
```xml
<gap:plugin name="de.appplant.cordova.plugin.badge" version="0.5.1" />
```
More informations can be found [here][PGB_plugin].


## Using the plugin
The plugin creates the object ```window.plugin.notification.badge``` with the following interface:

### Plugin initialization
The plugin and its methods are not available before the *deviceready* event has been fired.

```javascript
document.addEventListener('deviceready', function () {
    // window.plugin.notification.badge is now available
}, false);
```

### Set the badge of the app icon
The badge of the app can be set through the `notification.badge.set` interface.<br>
The method takes the badge as its argument. It needs to be a number or a string which can be parsed to a number.

#### Further informations
- On Android the badge will be displayed through a notification. See [setTitle][set_title] how to specify a custom notification title.
- On Windows Phone 8 the badge will be displayed through the app's live tile.
- See [get][get] how to get back the current badge of the app icon.
- See [clear][clear] of how to clear the badge of the app icon.
- See the [examples][examples] of how to use the plugin.

```javascript
window.plugin.notification.badge.set(Number);
```

### Get the badge of the app icon
The badge of the app can be accessed through the `notification.badge.get` interface.<br>
The method takes a callback function as its argument which will be called with the badge number. Optional the scope of the callback function ca be defined through a second argument.

```javascript
window.plugin.notification.badge.get( function (badge) {
	// console.log('Badge of the app icon: ' + badge);
}, scope);
```

### Clear the badge of the app icon
The badge of the app can be removed through the `notification.badge.clear` interface.

#### Further informations
- Clearing the badge number is equivalent to set a zero number.
- See [setClearOnTap][set_clear_on_tap] how to clear the badge automatically after the user has taped the app icon.
- See [set][set] of how to set the badge of the app icon.

```javascript
window.plugin.notification.badge.clear();
```

### Clear the badge automatically if the user taps the app icon
The badge of the app can be cleared automatically after the user has taped the app icon through the `notification.badge.setClearOnTap` interface.<br>
The method takes an argument which tells to clear the badge or not. The default value is *false*.

```javascript
window.plugin.notification.badge.setClearOnTap(Boolean);
```


##  Examples
### Set the badge of the app icon
The following example shows how to set the badge of the app icon to **1**.

```javascript
window.plugin.notification.badge.set(1);
// or
window.plugin.notification.badge.set('1');
```

### Clear the badge of the app icon
See below how to clear the badge of the app icon.

```javascript
window.plugin.notification.badge.clear();
// or
window.plugin.notification.badge.set(0);
```

### Clear the badge automatically if the user taps the app icon
The code below tells the plugin to clear the badge each time the user taps the app icon.

```javascript
window.plugin.notification.badge.setClearOnTap(true);
```


## Platform specifics
### Specify custom notification title on Android
The default format for the title is `%d new messages`, but is customizable through `setTitle`.

```javascript
window.plugin.notification.badge.setTitle('%d neue Meldungen');
```

## Quirks
### TypeError: Cannot read property 'currentVersion' of null
The `version.bat` script can to be renamed to `version` as a workaround.
{'fraction_non_alphanumeric': 0.1075730595998743, 'fraction_numerical': 0.0027233685974651723, 'mean_word_length': 4.741431148526759, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '585764', 'n_tokens_mistral': 2759, 'n_tokens_neox': 2584, 'n_words': 1177}