npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@danyalwe/capacitor-battery

v0.0.4

Published

Get access to every info about the device battery!

Readme

Capacitor Plugin - Battery

Get access to every info about the device battery!

Supported Android version: 21+
Supported iOS version: Not supported
Supported Browsers: Chromium-based

Install

npm install @danyalwe/capacitor-battery
npx cap sync

Todos

  • [ ] Add support for iOS

Supported methods

| Name | Android | iOS | Web | | :----------------- | :------ | :-- | :-- | | start | ✅ | ❌ | ✅ | | stop | ✅ | ❌ | ✅ | | addListener | ✅ | ❌ | ✅ | | removeAllListeners | ✅ | ❌ | ✅ |

Supported properties

| Property | Android | iOS | Web | | :-------------------- | :------ | :-- | :-- | | currentCapacity | ✅ | ❌ | ❌ | | totalCapacity | ✅ | ❌ | ❌ | | realPercentage | ✅ | ❌ | ❌ | | technology | ✅ | ❌ | ❌ | | temperature | ✅ | ❌ | ❌ | | voltage | ✅ | ❌ | ❌ | | amperage | ✅ | ❌ | ❌ | | wattage | ✅ | ❌ | ❌ | | health | ✅ | ❌ | ❌ | | status | ✅ | ❌ | ❌ | | chargeMode | ✅ | ❌ | ❌ | | level | ✅ | ❌ | ✅ | | hasBattery | ✅ | ❌ | ✅ | | isCharging | ✅ | ❌ | ✅ | | chargingTime | ❌ | ❌ | ✅ | | dischargingTime | ❌ | ❌ | ✅ |

API

Represents the BatteryPlugin interface.

start()

start() => Promise<BatteryInfos | undefined>

Starts the battery plugin and returns the battery information.

Returns: Promise<BatteryInfos>


stop()

stop() => Promise<void>

Stops the battery plugin.


addListener('batteryChange', ...)

addListener(eventName: 'batteryChange', listenerFunc: (event: BatteryInfos) => void) => Promise<PluginListenerHandle>

Adds a listener for the 'batteryChange' event.

| Param | Type | Description | | ------------------ | ------------------------------------------------------------------------- | --------------------------------------------------------------- | | eventName | 'batteryChange' | The name of the event. | | listenerFunc | (event: BatteryInfos) => void | The listener function to be called when the event is triggered. |

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Removes all listeners for the 'batteryChange' event.


Interfaces

BatteryInfos

Represents the battery information of the device.

| Prop | Type | Description | | --------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | level | number | The current battery level as a percentage (0-100). | | hasBattery | boolean | Whether the device has a battery or not. | | isCharging | boolean | Whether the device is currently charging or not. | | chargingTime | number | The estimated time remaining until the battery is fully charged (in minutes). Only available when charging. | | dischargingTime | number | The estimated time remaining until the battery is fully discharged (in minutes). Only available when discharging. | | currentCapacity | number | The current battery capacity (in mAh). Only available on some devices. | | totalCapacity | number | The total battery capacity (in mAh). Only available on some devices. | | realPercentage | number | The real battery percentage, which may differ from the reported percentage. Only available on some devices. | | technology | string | The technology used in the battery. Only available on some devices. | | temperature | number | The current temperature of the battery (in Celsius). Only available on some devices. | | voltage | number | The current voltage of the battery (in volts). Only available on some devices. | | amperage | number | The current amperage of the battery (in amperes). Only available on some devices. | | wattage | number | The current wattage of the battery (in watts). Only available on some devices. | | health | BatteryHealth | The health status of the battery. Only available on some devices. | | status | BatteryStatus | The status of the battery. Only available on some devices. | | chargeMode | BatteryChargeMode | The charging mode of the battery. Only available on some devices. |

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

Enums

BatteryHealth

| Members | Description | | ------------------ | ----------------------------------------- | | UNKNOWN | The health status is unknown. | | COLD | The battery is cold. | | DEAD | The battery is dead. | | GOOD | The battery is in good health. | | OVERHEAT | The battery is overheating. | | OVER_VOLTAGE | The battery is experiencing over voltage. | | FAILURE | The battery has failed. |

BatteryStatus

| Members | Description | | ------------------ | ------------------------------ | | UNKNOWN | The battery status is unknown. | | NOT_CHARGING | The battery is not charging. | | DISCHARGING | The battery is discharging. | | CHARGING | The battery is charging. | | FULL | The battery is full. |

BatteryChargeMode

| Members | Description | | -------------- | -------------------------------------------------------- | | UNKNOWN | The charging mode is unknown. | | AC | The battery is being charged through an AC power source. | | USB | The battery is being charged through a USB connection. | | DOCK | The battery is being charged through a docking station. | | WIRELESS | The battery is being charged wirelessly. |