Do phone calls kill apps?

Discussion in 'iOS Programming' started by milktooth, Nov 2, 2009.

  1. macrumors member

    Joined:
    Oct 30, 2009
    #1
    No. People do.



    I only have an iPod touch and don't have access to an iPhone. I'm writing a countdown timer app but have concerns that incoming calls would interrupt its function.

    What happens when phone calls are received or made? Are apps left running in the background?

    Would an [NSTimer scheduledTimerWithTimeInterval...] be interrupted?
     
  2. macrumors Nehalem

    GoCubsGo

    Joined:
    Feb 19, 2005
    #2
    No apps run in the background of a non-jailbroken iPhone.
     
  3. thread starter macrumors member

    Joined:
    Oct 30, 2009
    #3
    From Apple:

    Even if your application is not designed to use iPhone-specific features like the camera, GPS, or Compass, when it runs on an iPhone it can encounter a number of unique situations. For instance, if a user accepts an incoming phone call while using your application, your application will quit. It must be prepared to handle this behavior. The right thing is to restore the user's state when they relaunch the application.
     
  4. macrumors regular

    xsmasher

    Joined:
    Jul 18, 2008
    #4
    You can use the timer in the "clock" app to simulate an interruption. If the user gets a call you get applicationWillResignActive, if they decline the call you get applicationDidBecomeActive, and if they take the call your app gets terminated.

    To simulate this, set a clock alarm for one minute and start your app. When the alarm window appears, you can click "ok" to simulate ignoring the call, or click the home button to simulate taking the call.
     
  5. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #5
    Sorry for butting in, I'm not a programmer, but I wondered... how is it that there were some programs in the past that could stay in a locked/paused state when a call came in? Gameloft's Ferrari GT -- this is an older game now -- could definitely do this.
     
  6. macrumors regular

    xsmasher

    Joined:
    Jul 18, 2008
    #6
    You "fake it" by pausing the game when you lose focus, and saving the game when you get the termination message. When the game is started again, you look for a saved game file and load it if it exists. That's What I do in "Dead Panic."
     
  7. Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #7
    That's possible, but it doesn't seem to be what that old app did -- now granted, this was some time and a number of OS revisions ago. It came back pretty instantly in paused mode (as opposed to any loading delay). I'd be curious to load it back on my iPhone and see if it still does this.
     

Share This Page