Cannot find name 'BatteryStatusResponse'


I’m using the Ionic Native plugin for the battery (import { BatteryStatus } from ‘@ionic-native/battery-status’

I’m doing exactly the same as the example:

// watch change in battery status
let subscription = this.batteryStatus.onChange().subscribe(
(status: BatteryStatusResponse) => {
console.log(status.level, status.isPlugged);
// stop watch

But I keep getting the error 'Cannot find name ‘BatteryStatusResponse’?

Many thanks



I eventually got this working:

Put these in your class

private batterySubscription: Subscription;
public batteryLevel: number;
public pluggedInString: string;

this.batterySubscription = this.batteryStatus.onChange().subscribe(
(status: BatteryStatusResponse) => {
this.batteryLevel = status.level;
if (status.isPlugged === true) {
this.pluggedInString = ‘(Charging: AC)’;
} else {
this.pluggedInString = ‘Not Charging’;
console.log('LEVEL ’ + status.level + ’ PLUGGED IN ’ + status.isPlugged);

The above should goto ngOInit()

and then have:

ionViewWillLeave() {

Unfortunately my view isn’t updating when new values come in, so you have to leave and come back to see the update. But it’s better than nothing.