O'Reilly logo

PhoneGap Essentials by Ivan Turkovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Battery Status plugin

One of the important needs of an application is to know the current battery state so it can handle data correctly, and to ensure the battery does not run out before being able to save crucial data information, or take a crucial action.

There are three events that are especially useful for developing applications; they are related to the battery charge and determining when the battery state is critical, so you know when to save or back up data.

To install the following plugin, you need to run the following command:

phonegap plugin add cordova-plugin-battery-status

With this plugin, you need to run examples on the physical device since the simulator does not provide data for it. There are alternatives available, such as the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required