Swift

how to detect low power mode in swift

How to detect low power mode in swift

What is low power mode?
Low power mode is a new way that apple is tackling their ever dwindling batteries. It stops all background activity, dims the screen and uses different assets to save power. It’s pretty neat to be fair, I have survived on 1% for half an hour before. I know, Sounds like a lie, but trust me. It isn’t.

The first thing we need to do is declare some variables at the top. So, in your ViewController.Swift file. just under the class declaration, write:

 

When that method is triggered, you can check the new value of isLowPowerModeEnabled to see what state the device is in: