Battery Status
Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the BatteryStatus plugin docs.
https://github.com/apache/cordova-plugin-battery-status
Stuck on a Cordova issue?
If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.
Installation#
- Capacitor
- Cordova
- Enterprise
$ npm install cordova-plugin-battery-status $ npm install @ionic-native/battery-status $ ionic cap sync
$ ionic cordova plugin add cordova-plugin-battery-status $ npm install @ionic-native/battery-status
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us
#
Supported Platforms- iOS
- Android
- Windows
- Browser
#
Usage#
ReactLearn more about using Ionic Native components in React
#
Angularimport { BatteryStatus } from '@ionic-native/battery-status/ngx';
constructor(private batteryStatus: BatteryStatus) { }
...
// watch change in battery statusconst subscription = this.batteryStatus.onChange().subscribe(status => { console.log(status.level, status.isPlugged);});
// stop watchsubscription.unsubscribe();