WWDC 2015

Achieving All-Day Battery

iOS 9

per-app battery usage low power mode environmental factors inteligent suggestions

Xcode

iOS energy gauge

  • CPU
  • Networking
  • Location
  • Background Location instrument

Energy = Power x time

use lesser Power -> lengthen the usage time

  • Eliminate polling and timers
  • Response to user action and being idle
  • Do the work later and allow delay
  • Batch work

Networking -

  • beware high,fixed power costs
  • Design it by using minimal cost
  • try to coalesced -- group the networking together and not to do long networking
  • Background update and use NSURLSession
  • use notification sparingly

Location -

  • Don't keep updating location unless need to
  • invoke startUpdatingLocation() when need to
  • call stopUpdatingLocation() asap
  • use requestLocation() in iOS 9 for a quick grab of user's location
  • locationManager.allowsBackgroundLocationUpdates = false to make sure the background locational update is not performed
  • lower accuracy saves power
  • set alowDeferredLocationUpdateUntilTraveled:timeout: to give tolerance for system to perform location update while saving power

Background operation - Don't delay "real" sleep

  • startBackgroundTask() keeps device awake
  • only start for non-trivial user work
  • call endBackgroundTask() asap