BatteryMonitor

public class BatteryMonitor : BaseNotificationMonitor

A BatteryMonitor instance monitors the device for changes to the charge state and charge level of its battery.

  • Encapsulates changes to the battery state or battery level of the device.

    See more

    Declaration

    Swift

    public enum Event
  • Specifies which events to monitor.

    See more

    Declaration

    Swift

    public struct Options : OptionSet
  • Initializes a new BatteryMonitor.

    Declaration

    Swift

    public init(options: Options = .all,
                queue: OperationQueue = .main,
                handler: @escaping (Event) -> Void)

    Parameters

    options

    The options that specify which events to monitor. By default, all events are monitored.

    queue

    The operation queue on which the handler executes. By default, the main operation queue is used.

    handler

    The handler to call when the battery state or battery level of the device changes.

  • The battery charge level for the device.

    Declaration

    Swift

    public var level: Float { get }
  • The battery state for the device.

    Declaration

    Swift

    public var state: UIDeviceBatteryState { get }
  • Declaration

    Swift

    override public func addNotificationObservers()
  • Declaration

    Swift

    override public func removeNotificationObservers()