@danyalwe/capacitor-battery
v1.0.0
Published
Capacitor plugin for battery monitoring
Downloads
229
Readme
Capacitor Plugin - Battery
Get access to every info about the device battery!
Supported Android version: 24+
Supported iOS version: Not supported
Supported Browsers: Chromium-based
Install
npm install @danyalwe/capacitor-battery
npx cap syncTodos
- [ ] 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.
Interfaces
BatteryInfo
Represents the battery information of the device.
| Prop | Type | Description |
| ------------------- | -------------------- | ---------------------------------------- |
| totalCapacity | number | The total battery capacity (in mAh). |
| technology | string | The technology used in the battery. |
| hasBattery | boolean | Whether the device has a battery or not. |
BatteryData
Represents the battery data that can change over time.
| Prop | Type | Description |
| --------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| level | number | The current battery level as a percentage (0-100). |
| isCharging | boolean | Whether the device is currently charging or not. |
| chargingTime | number | The estimated time remaining until the battery is fully charged (in minutes). |
| dischargingTime | number | The estimated time remaining until the battery is fully discharged (in minutes). |
| currentCapacity | number | The current battery capacity (in mAh). |
| realPercentage | number | The real battery percentage, which may differ from the reported percentage. |
| temperature | number | The current temperature of the battery (in Celsius). |
| voltage | number | The current voltage of the battery (in volts). |
| amperage | number | The current amperage of the battery (in amperes). |
| wattage | number | The current wattage of the battery (in watts). |
| health | BatteryHealth | The health status of the battery. |
| status | BatteryStatus | The status of the battery. |
| chargeMode | BatteryChargeMode | The charging mode of the battery. |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
Type Aliases
BatteryHealth
(typeof BatteryHealths)[number]
BatteryStatus
(typeof BatteryStatuses)[number]
BatteryChargeMode
(typeof BatteryChargeModes)[number]
