Battery Status

Contents

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

https://github.com/apache/cordova-plugin-battery-status

Ionic 电量Battery Status插件的安装(Installation)

ionic cordova plugin add cordova-plugin-battery-status npm install @ionic-native/battery-status

Ionic 电量Battery Status插件支持的平台(Supported Platforms)

  • iOS
  • Android
  • Windows
  • Browser

Ionic 电量Battery Status插件的用法(Usage)

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

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();