Battery Status
$ ionic plugin add cordova-plugin-batterystatus
Repo: https://github.com/apache/cordova-plugin-battery-status
Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the BatteryStatus plugin docs.
Supported platforms
- Amazon Fire OS
- iOS
- Android
- BlackBerry 10
- Windows Phone 7
- Windows Phone 8
- Windows
- Firefox OS
- Browser
Usage
import {BatteryStatus} from 'ionic-native';
// watch change in battery status
let subscription = BatteryStatus.onChange().subscribe(
status => {
console.log(status.level, status.isPlugged);
}
);
// stop watch
subscription.unsubscribe();
Static Methods
onChange()
Watch the change in battery level
Returns:
Observable
Returns an observable that pushes a status object
onLow()
Watch when the battery level goes low
Returns:
Observable<StatusObject>
Returns an observable that pushes a status object
onCritical()
Watch when the battery level goes to critial
Returns:
Observable<StatusObject>
Returns an observable that pushes a status object