cordova-plugin-battery-status icon indicating copy to clipboard operation
cordova-plugin-battery-status copied to clipboard

Conflicts with cordova-plugin-firebase

Open arrrash opened this issue 7 years ago • 10 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

arrrash avatar Aug 28 '18 05:08 arrrash

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

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

janpio avatar Aug 28 '18 07:08 janpio

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.

arrrash avatar Aug 29 '18 22:08 arrrash

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?

janpio avatar Aug 30 '18 08:08 janpio

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.

janpio avatar Aug 30 '18 08:08 janpio

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

arrrash avatar Aug 31 '18 04:08 arrrash

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

cyptus avatar Apr 17 '19 12:04 cyptus

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

sbrannstrom avatar Sep 01 '19 07:09 sbrannstrom

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: https://github.com/ionic-team/ionic-native/issues/2972

cyptus avatar Sep 02 '19 09:09 cyptus

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.

sbrannstrom avatar Sep 02 '19 11:09 sbrannstrom

@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.

EYALIN avatar Apr 11 '23 13:04 EYALIN