Keeping an app running when screen lock kicks in

Discussion in 'iOS Programming' started by adamkharris, Oct 17, 2016.

  1. adamkharris macrumors newbie

    adamkharris

    Joined:
    Oct 17, 2016
    #1
    I have developed an app that is fairly resource hungry (a golf scoring app) an am having a bit of an issue. When the screen locks, either manually or by timer, I open the phone and my app has gone back to the springboard. It would be great if the app were sitting there after unlock but I can't seem to get this to happen.

    Any help or pointers would be great thanks, using Xcode.
     
  2. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #3
    iOS is very strict about what it keeps running in the background when the phone is not in use. If your app is very resource-intensive, and uses a lot of battery life....why keep it running in the background if it's just gonna drain people's batteries?

    What you should do is find a way to offload most of the resources & processes when the app is not in the foreground. Thus, when the screen is locked, deallocate most of your resources until the app is back in the foreground again. When you do this, iOS won't stop execution of your app.
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Is your app crashing? If you build one of the apps from Xcode templates does it act the same as your app?
     
  4. adamkharris thread starter macrumors newbie

    adamkharris

    Joined:
    Oct 17, 2016
    #5
    We have had a good look at this and according to my lead dev, all is okay with the code!
    --- Post Merged, Oct 18, 2016 ---
    On closer inspection, I am getting sporadic crashing.

    I have my scorecard on the app running and after the lock screen kicks in, we just see the springboard (not always) and opening the app essentially just runs it from the start. Not always but a little too often :-/

    Frustrating.
    --- Post Merged, Oct 18, 2016 ---
    Good points and taken on board, thanks
     
  5. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    To track down crashes you want either to run the app in the Debugger and make it crash or Run the app without the debugger and look at the crash log that's generated. If your app is being killed for using too much memory that will also be shown in the crash logs.
     

Share This Page