# Battery Status Plugin

Tested Version: [2.0.2](https://github.com/apache/cordova-plugin-battery-status/releases/tag/2.0.2)

{% hint style="info" %}
This document is based on the original Cordova docs available at [Cordova Docs](https://github.com/apache/cordova-plugin-battery-status).
{% endhint %}

This plugin provides an implementation of an old version of the [Battery Status Events API](http://www.w3.org/TR/2011/WD-battery-status-20110915/). It adds the following three events to the `window` object:

* batterystatus
* batterycritical
* batterylow

Applications may use `window.addEventListener` to attach an event listener for any of the above events after the `deviceready` event fires.

## Plugin ID

```javascript
cordova-plugin-battery-status
```

## Adding the Plugin

In order to use this plugin, please [enable](/products_guide/monaca_ide/dependencies/cordova_plugin.md#import-cordova-plugins) `Battery` plugin in Monaca Cloud IDE.

## API Reference

### Status object

All events in this plugin return an object with the following properties:

| Property    | Type    | Description                                |
| ----------- | ------- | ------------------------------------------ |
| `level`     | Number  | The battery charge percentage (`0-100`)    |
| `isPlugged` | Boolean | Indicates whether the device is plugged in |

### batterystatus event

Fires when the battery charge percentage changes by at least `1 percent`, or when the device is plugged in or unplugged. Returns an [object](/reference/core-cordova-plugins/cordova_9.0/battery-status.md#status-object) containing battery status.

#### Example

```javascript
window.addEventListener("batterystatus", onBatteryStatus, false);

function onBatteryStatus(status) {
    console.log("Level: " + status.level + " isPlugged: " + status.isPlugged);
}
```

#### Supported Platforms

* iOS
* Android

#### Quirks: Android

{% hint style="danger" %}
The Android implementations are greedy and prolonged use will drain the device's battery.&#x20;
{% endhint %}

### batterylow event

Fires when the battery charge percentage reaches the low charge threshold. This threshold value is device-specific. Returns an [object](/reference/core-cordova-plugins/cordova_9.0/battery-status.md#status-object) containing battery status.

#### Example

```javascript
window.addEventListener("batterylow", onBatteryLow, false);

function onBatteryLow(status) {
    alert("Battery Level Low " + status.level + "%");
}
```

#### Supported Platforms

* iOS
* Android

### batterycritical event

Fires when the battery charge percentage reaches the critical charge threshold. This threshold value is device-specific. Returns an [object](/reference/core-cordova-plugins/cordova_9.0/battery-status.md#status-object) containing battery status.

#### Example

```javascript
window.addEventListener("batterycritical", onBatteryCritical, false);

function onBatteryCritical(status) {
    alert("Battery Level Critical " + status.level + "%\nRecharge Soon!");
}
```

#### Supported Platforms

* iOS
* Android

See Also:

* [Third-party Cordova Plugins](/reference/third_party_phonegap.md)
* [Core Cordova Plugins](/reference/core-cordova-plugins.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://en.docs.monaca.io/reference/core-cordova-plugins/cordova_9.0/battery-status.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
