• Save
iOS Backgrounding - SLC Cocoaheads
Upcoming SlideShare
Loading in...5
×
 

iOS Backgrounding - SLC Cocoaheads

on

  • 1,079 views

Presentation for the September 2011 Salt Lake City Cocoaheads group. Covers the basics of how iOS apps terminate, resume, and what you can do in the background.

Presentation for the September 2011 Salt Lake City Cocoaheads group. Covers the basics of how iOS apps terminate, resume, and what you can do in the background.

Statistics

Views

Total Views
1,079
Views on SlideShare
965
Embed Views
114

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 114

http://www.stevensonsoftware.com 114

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

iOS Backgrounding - SLC Cocoaheads iOS Backgrounding - SLC Cocoaheads Presentation Transcript

  • BackgroundingBursting Your Bubble on iOS
  • SorryDoing what you want in the backgroundis almost impossible
  • photo by protographer23
  • Get Your Notepads ReadySuspending vs. ResumingLocal NotificationsDoing Stuff in the Background
  • Exiting vs. ResumeSince iOS 4, you can keep your app“open” on exitBut it’s really just a “freeze” andresume - nothing happens while it’sin the background
  • Resume MeSet the ‘UIApplicationExitsOnSuspend’to ‘NO’ in your Info.plist
  • App Delegate Events App Initial Load -> Exit: applicationDidBecomeActive applicationWillResignActive applicationDidEnterBackground On Relaunch: applicationWillEnterForeground
  • Sounds PromisingapplicationDidEnterBackground soundspromising, but you can’t do anythinginside it that is long-running. Docs say you have 5 seconds You can’t get back to the UI
  • Terminate on ExitSet ‘UIApplicationExitsOnSuspend’ to‘YES’ in your Info.plist
  • App Delegate Events App Launch -> Exit: applicationDidBecomeActive applicationDidEnterBackground applicationWillTerminate
  • Kill MeIf the user does the jiggle and Red-Xes the app, no events are fired
  • DEMO!
  • Local NotificationsYou can schedule local notificationsto prompt the user at a future timeeven if your app isn’t runningUseful - but remember the user isn’trequired to open the app, and yournotification may never appear
  • DEMO!
  • Ok, NextSo you “can” do things in thebackground, but it’s limited to 3things: Get GPS updates Play Justin Bieber Do the VOIP
  • Set Your PlistDo do one of those 3 lovely things inthe background, set the‘UIBackgroundModes’ in yourInfo.plistValues are: location, audio, voip
  • LocationGet super duper real-time updates ormajor changes onlyUse CLLocationManager to do the magic
  • DEMO!
  • Playing AudioIt’s easy: start playing your tunesusing AV* framework.If something else starts playingmusic, you lose
  • DEMO!
  • VOIPSorry, no demo.But supposedly you can open a socketand keep it open.
  • Fighting the ManPeople have tried tricking the systemby playing an “empty” sound file.This works until some other app playssound.GPS Updates take up battery power, soyour users may hate you.
  • ConclusionRead more at: http://developer.apple.com/library/ios/ #documentation/iphone/conceptual/ iphoneosprogrammingguide/ BackgroundExecution/ BackgroundExecution.htmlSample Code: https://github.com/dnstevenson/BackgroundTestGood Luck!
  • Thanks!Find me on Twitter @dnstevensonBuy one of my apps at http://www.stevensonsoftware.comLeave me a 5-star review and I’ll beyour best friend