user3042719 user3042719 - 4 years ago 110
Swift Question

Swift - Get if battery is charging even at 100%

I am making an app in swift, and I need to know if the battery is charging. I know I can use

UIDevice.currentDevice().batteryState
, But when it is at 100%, it returns
.Full
instead of
.Charging
. It also returns
.Full
when unplugged on 100%. So is there a way to determine if the battery is charging while at 100%?

Answer Source

You said,

It also returns .Full when unplugged on 100%.

But the docs say (emphasis mine):

UIDeviceBatteryStateFull

The device is plugged into power and the battery is 100% charged.

So it seems like the state should change to .Unplugged once you remove power. If you are seeing .Full when the battery is both unplugged and fully charged then that’s a bug (or at least an error in the documentation) and you should report it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download