iOhYes Retired


A podcast by iOS developers for iOS developers, delivering news, tips, and rants for professional iOS/Mac developers, with something for enterprise and indie developers alike.

Hosted by Darryl Thomas and John Sextro.

← Previous Episode   |   Next Episode →

92: Background on Background

November 11, 2015 at 10:00AM • 1 hour 3 minutes • Wiki Entry

Nolan and Darryl discuss background operations on iOS, including some of the less-obvious pitfalls you can avoid.

Tweet Shoutouts

Discussion: Background work

  • Getting the User’s Attention
    • Local Notification
  • Background Data Callbacks
  • Elevated Multitasking Background Work
    • VoIP
    • Audio / Airplay
      • This is what Facebook has been scrutinized for
  • Background Processing Work
    • [UIApplication backgroundTimeRemaining] - (10 seconds with no background tasks/fetches running)
    • Background work is often paired with greatly diminished CPU priority and can often end up with as little as 4% of the CPU
    • Background Tasks *[UIApplication beginBackgroundTaskWithName:expirationHandler:]
      • [UIApplication endBackgroundTask:]
      • [UIApplication backgroundTimeRemaining] - (600 secs pre-iOS 7, otherwise 180 secs)
    • Background Fetch
      • Project checkbox “Background Fetch” to enable
      • Specify [UIApplication setMinimumBackgroundFetchInterval:]
        • Minimum == as frequently as the OS will permit
        • Never == disable BG fetch callbacks
      • [UIApplication backgroundTimeRemaining] - (~45 secs)
    • Push Fetch
      • Effectively the same behavior as background fetch
    • Background URL Sessions
      • Download to file or Upload from file
      • Performed out of process
      • Calls back either on completion or when authentication is needed
  • Remember to clean up when going into the background
    • No OpenGL
    • Suspend timers
    • Expect Network Failures
    • Clean up Bonjour and other shared resources (Address Book, Calendar, etc)
    • Clear sensitive info from screen
    • Clean up alerts (if needed)
    • Stop updating UI
    • Save the app state
    • Clear unneeded resources
    • Clean up Audio Sessions (Facebook Bug)
  • Opt out
    • Set UIApplicationExitsOnSuspend to YES