Nolan and Darryl discuss background operations on iOS, including some of the less-obvious pitfalls you can avoid.
Tweet Shoutouts
@iOhYesPodcast I didn’t get an Apple TV dev kit, nor will buy it. As long as @netflix & co will support rev 3 I’ll stick with it— You can call me Joe (@mokagio) November 5, 2015
@iOhYesPodcast overscan on the ?TV is killing me. Fairly old but 1080p60 tv has no adjustments! Consoles have own controls, ?TV has none ????— Ashton Williams (@AshtonDev) November 5, 2015
@AshtonDev @iOhYesPodcast and imho, the margin guides ought to be set to the content-safe borders.— Darryl H. Thomas (@dh_thomas) November 5, 2015
@dh_thomas @iOhYesPodcast yeah surprised you have to add the safe zone guides yourself https://t.co/HyW9m028Qx @jim_rutherford— Ashton Williams (@AshtonDev) November 5, 2015
@iOhYesPodcast @Plex for the new #AppleTV is fantastic. Good design and excellent PQ when running movies from my NAS. Plus, it’s #free!— BaraLabs, LLC (@BaraLabs) November 5, 2015
How do you get the WWDC videos on the new Apple TV? And the apple events?— ????? (@scottaw) November 6, 2015
@scottaw @RonnieLutes1 I do have this github link from @dh_thomas on this weeks @iOhYesPodcast to roll your own.
https://t.co/v8liidTHDZ— Vic Hudson (@vichudson1) November 6, 2015
Discussion: Background work
Getting the User’s Attention
Local Notification
Background Data Callbacks
Bluetooth Location Updates Newsstand Downloads Accessory callbacks
WWDC 2014 Session 701 - Designing Accessories for iOS and OS X
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
Picks
Nolan
Background Modes in Swift
Darryl
Anova Precision Cooker Wi-Fi