@danyalwe/capacitor-battery
v0.0.2
Published
Capacitor plugin to get access to every info about the device battery
Downloads
3
Maintainers
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
- [ ] Improve documentation, add JSDoc strings
- [ ] 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
start()
start() => Promise<Battery | undefined>
Returns: Promise<Battery>
stop()
stop() => Promise<void>
addListener('batteryChange', ...)
addListener(eventName: 'batteryChange', listenerFunc: (event: Battery) => void) => Promise<PluginListenerHandle>
| Param | Type |
| ------------------ | --------------------------------------------------------------- |
| eventName
| 'batteryChange' |
| listenerFunc
| (event: Battery) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>
Interfaces
Battery
| Prop | Type |
| --------------------- | --------------------------------------------------------------- |
| level
| number |
| hasBattery
| boolean |
| isCharging
| boolean |
| chargingTime
| number |
| dischargingTime
| number |
| currentCapacity
| number |
| totalCapacity
| number |
| realPercentage
| number |
| technology
| string |
| temperature
| number |
| voltage
| number |
| amperage
| number |
| wattage
| number |
| health
| BatteryHealth |
| status
| BatteryStatus |
| chargeMode
| BatteryChargeMode |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Enums
BatteryHealth
| Members |
| ------------------ |
| UNKNOWN
|
| COLD
|
| DEAD
|
| GOOD
|
| OVERHEAT
|
| OVER_VOLTAGE
|
| FAILURE
|
BatteryStatus
| Members |
| ------------------ |
| UNKNOWN
|
| NOT_CHARGING
|
| DISCHARGING
|
| CHARGING
|
| FULL
|
BatteryChargeMode
| Members |
| -------------- |
| UNKNOWN
|
| AC
|
| USB
|
| DOCK
|
| WIRELESS
|