kaios-types
    Preparing search index...

    Interface BatteryManager

    The BatteryManager interface provides information about the system's battery charge level. It is returned by the navigator.getBattery() method.

    navigator.getBattery().then((battery) => {
    console.log(`Battery level: ${battery.level * 100}%`);
    console.log(`Charging: ${battery.charging}`);

    battery.addEventListener('levelchange', () => {
    console.log(`Battery level changed to ${battery.level * 100}%`);
    });
    });
    interface BatteryManager {
        charging: boolean;
        chargingTime: number;
        dischargingTime: number;
        health: string;
        level: number;
        onbatteryhealthchange: ((this: BatteryManager, ev: Event) => any) | null;
        onchargingchange: ((this: BatteryManager, ev: Event) => any) | null;
        onchargingtimechange: ((this: BatteryManager, ev: Event) => any) | null;
        ondischargingtimechange: ((this: BatteryManager, ev: Event) => any) | null;
        onlevelchange: ((this: BatteryManager, ev: Event) => any) | null;
        present: boolean;
        temperature: number;
        addEventListener(
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | AddEventListenerOptions,
        ): void;
        dispatchEvent(event: Event): boolean;
        removeEventListener(
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | EventListenerOptions,
        ): void;
    }

    Hierarchy

    • EventTarget
      • BatteryManager
    Index

    Properties

    charging: boolean

    A Boolean value indicating whether the battery is currently being charged.

    chargingTime: number

    A number representing the remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged or not charging.

    dischargingTime: number

    A number representing the remaining time in seconds until the battery is completely discharged and the system suspends.

    health: string

    Battery health status. Available in KaiOS 2.5+.

    level: number

    A number representing the system's battery charge level scaled to a value between 0.0 and 1.0. A value of 0 means the battery is empty and the system is about to be suspended. A value of 1.0 means the battery is full. A value of 1.0 is also returned if the system is unable to determine the battery charge level.

    onbatteryhealthchange: ((this: BatteryManager, ev: Event) => any) | null

    Event handler called when the battery health changes. Available in KaiOS 2.5+.

    onchargingchange: ((this: BatteryManager, ev: Event) => any) | null

    Event handler called when the charging state changes.

    onchargingtimechange: ((this: BatteryManager, ev: Event) => any) | null

    Event handler called when the chargingTime property changes.

    ondischargingtimechange: ((this: BatteryManager, ev: Event) => any) | null

    Event handler called when the dischargingTime property changes.

    onlevelchange: ((this: BatteryManager, ev: Event) => any) | null

    Event handler called when the level property changes.

    present: boolean

    Boolean indicating whether the battery is present. Available in KaiOS 2.5+.

    temperature: number

    Battery temperature value. Available in KaiOS 2.5+.

    Methods

    • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void