apache / cordova-plugin-battery-status

Apache Cordova Battery Status Plugin

Home Page:https://cordova.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conflicts with cordova-plugin-firebase

arrrash opened this issue · comments

In our Ionic project after installing cordova-plugin-firebase the battery-status loses its functionality.
But when we remove cordova-plugin-firebase it work fine.

Will be appreciated if you can help in this regard.

more info :
cordova -v -> 8.0.0

Which OS? OS version?
What Cordova Platform version?
What plugin version?

Any error messages or what does "loses its functionality" mean?

I am on macOS high Sierra 10.13.6
Cordova Version is 8.0.0
Plugin version ->

actually there is no error of any type during build or after build. Simply the event on battery-status is not present any more.

OS = Android, iOS?
Cordova Platform = e.g cordova-android 7.1.1
Plugin Version should not be empty - if you posted some code, use the <> button above the input field to make it visible.

What is your ionic info output?

Simply the event on battery-status is not present any more.

What does that mean, "not present"? Is it not triggered any more? Does it not exist any more?

Please try to recreate the problem with a new project created with cordova create. Put the demo project up on Github if you can reproduce it.

Hi there. plugin version is not empty, github seems to chopped it off. Both firebase and battery-status are are on their latest version.
the plugin exist but to working (i.e if you add window.alert for battery change status, if you add firebase plugin, the popup and all other methods in battery-status is not working)

firebase version atm : 0.1.22
Battery-status-version : 1.2.5

But I update both to the latest stable version but that does not help.
I will create a repo with these two to check how it works.

Ionic:

ionic (Ionic CLI) : 4.1.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic1 1.3.3
@ionic/v1-toolkit : 1.0.0

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : ios 4.5.5
Cordova Plugins : no whitelisted plugins (15 plugins total)

System:

ios-deploy : 2.0.0
ios-sim : 7.0.0
NodeJS : v10.8.0 (/usr/local/Cellar/node/10.8.0/bin/node)
npm : 6.2.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000

i got the exact same issue, is there any workaround available?

I have the same issue as well. Is there any update on this?

try registering the battery event with

import { fromEvent } from 'rxjs';
import { BatteryStatusResponse } from '@ionic-native/battery-status/ngx';

fromEvent<BatteryStatusResponse>(window, 'batterystatus').subscribe(async (status) => {
//...
});

instead of batteryStatus.onChange().subscribe(...) as a work around.

more info: danielsogl/awesome-cordova-plugins#2972

Thanks @cyptus but it's not working....

I'm calling this function from ngOnInit():

batteryStatus() {
    fromEvent<BatteryStatusResponse>(window, 'batterystatus').subscribe(async (status) => {
      this.batteryStats = status.level;
      console.log('Battery status: ', status);
      if (status.level !== null) {
        this.userService.updateUser({ batteryStatus: this.batteryStats });
      }
    });
  }

console logs this:

[console.log]: "Battery status : " {
"isTrusted": false,
"level": null,
"isPlugged": false
}

I don't know if I'm doing anything wrong but I can't get it to work at all.

commented

@janpio @arrrash @cyptus @sbrannstrom @infil00p Instead of maintaining this plugin only for me, I published a new maintained plugin called "community-cordova-plugin-battery-status" (https://github.com/EYALIN/community-cordova-plugin-battery-status) which is maintained and will keep being.
please feel free to use it, and write me any feedback.
can be installed by using "cordova plugin add community-cordova-plugin-battery-status"
all Android and IOS recent issues are fixed there.