Skip to content
0

katanakit-js / useGetBattery

Function: useGetBattery() ​

ts
function useGetBattery(): Promise<BatteryManager | null>;

Defined in: src/infrastructure/sensors/sensors.service.ts:315

Gets the device battery status.

Returns ​

Promise<BatteryManager | null>

A BatteryManager object or null if the API is unavailable.

Example ​

ts
const battery = await useGetBattery();
if (battery) {
  console.log(`${Math.round(battery.level * 100)}%`);
}

Released under the MIT License.