It’s always good that an app has different behavior when device is connected/disconnected to a power station, or has different battery levels. Your app can query the UIDevice#batteryLevel and UIDevice#batteryState properties at any time to determine the level of charge and the state of the battery.

Your app can also register to receive notifications when the battery level or state changes, using batteryLevelDidChangeNotification and batteryStateDidChangeNotification.

Compliant Code Example

let level = UIDevice.current.batteryLevel

or

let state = UIDevice.current.batteryState

or

NotificationCenter.default.addObserver(forName: UIDevice.batteryLevelDidChangeNotification, object: nil, queue: nil) { _ in }

or

NotificationCenter.default.addObserver(forName: UIDevice.batteryStateDidChangeNotification, object: nil, queue: nil) { _ in }