Instance Property

batteryLevel

The battery charge level for the device.

Declaration

var batteryLevel: Float { get }

Discussion

Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged). Before accessing this property, ensure that battery monitoring is enabled.

If battery monitoring is not enabled, battery state is UIDevice.BatteryState.unknown and the value of this property is –1.0.

See Also

Getting the Device Battery State

var isBatteryMonitoringEnabled: Bool

A Boolean value indicating whether battery monitoring is enabled (true) or not (false).

var batteryState: UIDevice.BatteryState

The battery state for the device.

enum UIDevice.BatteryState

The battery power state of the device.