Documentation Archive

Developer

Energy Efficiency Guide for iOS Apps

On This Page

React to Low Power Mode on iPhones

Users who wish to prolong their iPhone’s battery life can enable Low Power Mode under Settings > Battery. In Low Power Mode, iOS conserves battery life by enacting certain energy-saving measures. For example, the system may:

  • Reduce CPU and GPU performance

  • Pause discretionary and background activities, including networking

  • Reduce screen brightness

  • Reduce the timeout for auto-locking the device

  • Disable Mail fetch

  • Disable motion effects

  • Disable animated wallpapers

The mode automatically disables when the battery level rises to a sufficient level again.

Your app should take additional steps to help the system save energy when Low Power Mode is active. For example, your app could reduce the use of animations, lower frame rates, stop location updates, disable syncs and backups, and so on.

Register for Power State Notifications

Your app can register to receive notifications when the power state (Low Power Mode is enabled or disabled) of the device changes. These notifications are posted on the global dispatch queue. See Dispatch Queues in Concurrency Programming Guide.

To register for power state notifications, send the message addObserver:selector:name:object: to the default notification center of your app (an instance of NSNotificationCenter). Pass it a selector to call and NSProcessInfoPowerStateDidChangeNotification, as shown in Listing 7-1.

Once your app is notified of a power state change, it should then query isLowPowerModeEnabled to determine the current power state. See Listing 7-2. If Low Power Mode is active, then your app can take appropriate steps to reduce activity. Otherwise, it can resume normal operations.

Listing 7-1Registering for power state change notifications

Objective-C

  1. [[NSNotificationCenter defaultCenter] addObserver:self
  2. selector: @selector(yourMethodName:)
  3. name: NSProcessInfoPowerStateDidChangeNotification
  4. object: nil];

Swift

  1. NSNotificationCenter.defaultCenter().addObserver(
  2. self,
  3. selector: “yourMethodName:”,
  4. name: NSProcessInfoPowerStateDidChangeNotification,
  5. object: nil
  6. )

Determine the Power State

Your app can query the current power state at any time by accessing the isLowPowerModeEnabled property of the NSProcessInfo class, as shown in Listing 7-2. This property contains a boolean value, indicating whether Low Power Mode is enabled or disabled.

Listing 7-2Accessing the power state of a device

Objective-C

  1. if ([[NSProcessInfo processInfo] isLowPowerModeEnabled]) {
  2. // Low Power Mode is enabled. Start reducing activity to conserve energy.
  3. } else {
  4. // Low Power Mode is not enabled.
  5. };

Swift

  1. if NSProcessInfo.processInfo().lowPowerModeEnabled {
  2. // Low Power Mode is enabled. Start reducing activity to conserve energy.
  3. } else {
  4. // Low Power Mode is not enabled.
  5. }