Skip to main content

BatteryStatus

Object containing battery status information.

level

A number representing the system's battery charge level scaled to a value between 0.0 and 1.0.

Example:

console.log(battery.level); // 0.75

charging

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

Example:

console.log(battery.charging); // true

chargingTime

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

Example:

console.log(battery.chargingTime); // 1200

dischargingTime

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

Example:

console.log(battery.dischargingTime); // 3600

Device

Provides static methods for retrieving information about the current device. Useful for implementing platform-specific functionality or optimizations.

static operatingSystem(): string

Identifies the operating system, useful for adapting features or styles specific to different OS.

Example:

const os = Device.operatingSystem();
console.log(os); // 'iOS'

static isMobile(): boolean

Determines whether the device is a mobile device, useful for enabling/disabling mobile-specific features.

Example:

if (Device.isMobile()) {
console.log('Mobile device detected');
}

static batteryStatus(): Promise<BatteryStatus | null>

Retrieves the battery status of the device, if supported.

Example:

const status = await Device.batteryStatus();
if (status) {
console.log(`Battery level: ${status.level}`);
}