Low Power Mode debuted in iOS 9. It's a great way to get another hour or two of use out of a device.

When Apple first introduced this functionality, they touted how the feature turns of lots of little things that contribute to the battery savings.

It turns out we can actually provide these same savings in our own apps. Today we'll learn how. Let's get started:

The first way we'll interact with Low Power Mode is through a property on NSProcessInfo.

Here we're working on app that displays animated GIFs. When the user stops scrolling, we automatically begin looping the GIF. However, if the user has Low Power Mode enabled, we'll save a few CPU/GPU cycles by requiring the user to tap to start the animation:

func userStoppedScrolling () { guard NSProcessInfo . processInfo () . lowPowerModeEnabled == false else { return } gifView . beginPlaying () }

We'll finish up by registering for this NSNotification:

NSNotificationCenter . defaultCenter () . addObserver ( self , selector : "lowPowerModeChanged:" , name : NSProcessInfoPowerStateDidChangeNotification , object : nil )