Hi all,
I am trying to get the battery status of the device in my app.
After having installed::
cordova-plugin-battery-status
@ionic-native/battery-status
@ionic-native/core
I put BatteryStatus
into the module providers.
In the component, I have :
batterySubscription: Subscription;
batteryLevel: number = 100;
isBatteryPlugged: boolean = false;
constructor(private batteryStatus: BatteryStatus) { }
ngOnInit() {
this.initSubscriptions();
}
initSubscriptions() {
this.batterySubscription = this.batteryStatus.onChange().subscribe( (status:
BatteryStatusResponse) => {
console.log(status.level, status.isPlugged);
this.batteryLevel = status.level;
this.isBatteryPlugged = status.isPlugged;
});
}
Everything compiled perfectly, but the battery informations never change (as well in the browser as in the app). It doesn’t detect neither when I plug the computer nor when the battery level changes.
Has somebody an idea of the problem ? Thanks !