Battery Status

Contents

Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the BatteryStatus plugin docs.

Installation

ionic cordova plugin add cordova-plugin-battery-statusnpm install @ionic-native/battery-status
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEYnpm install @ionic-enterprise/battery-status

Supported Platforms

  • iOS
  • Android
  • Windows
  • Browser

Usage

import { BatteryStatus } from '@ionic-native/battery-status/ngx';

constructor(private batteryStatus: BatteryStatus) { }

...


// watch change in battery status
const subscription = this.batteryStatus.onChange().subscribe(status => {
   console.log(status.level, status.isPlugged);
});

// stop watch
subscription.unsubscribe();