1

Can closed apps (i.e. not running, or suspended) access background app refresh or modify their program state to gain access to background app refresh? And conversely, if background app refresh is disabled, can apps only access data in the foreground?

Example 1: Chat apps still get notifications if they are in the "not running" program state. How do they do this?

Example 2: If I'm saving a note (with background app refresh off), and I return to the homescreen before the note is finished saving, will it continue to save?

From the iOS docs, the app life cycle is pictured below.

State changes in an iOS app

iOS Developer Guide: The App Life Cycle

  • Are you asking how to code background app refresh? Apps can do refresh events in the background provided they follow the correct coding guidelines. How to do the coding is off-topic for this site. – fsb Oct 13 '16 at 15:08
  • @fsb It's not a programming question. But maybe I could get a better answer from iOS programmers. Which site would be more appropriate? – y3sh Oct 13 '16 at 16:10
  • The link you provided has the answers to your questions. If you read the Background Execution section you'll see how this is done. – fsb Oct 13 '16 at 16:19
  • @fsb As it turns out, BAR != Background execution... I think this is where my confusion came from. – y3sh Oct 13 '16 at 20:51
3

Do not confuse Suspended with Not Running. Suspended means the app is still in memory but otherwise not utilizing any resources. Not Running means the app is not in memory at all due to being involuntarily terminated, either because the system required resources for a foreground app, or because the user force-quit the app.

Background App Refresh (BAR) =/= "Background" as shown in that diagram:

  • BAR allows apps to update content on a very limited basis, on a schedule set and enforced by iOS, generally about once per day.

  • The Background state shown in that diagram is Background Execution, which allows apps to complete certain tasks in the background. BAR being disabled has no effect on apps being able to use Background Execution.

Background Execution is generally only allowed if an app has not been force-quit by the user (the exception being "location apps"). Apps in any state, including Terminated, can use Background Execution if they meet the requirements below. If necessary, they will be relaunched by the system into the background (again, subject to the force-quit limitations above). See my answer on a similar question:

  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that record audio content while in the background
  • Apps that keep users informed of their location at all times, such as a navigation app
  • Apps that support Voice over Internet Protocol (VoIP)
  • Apps that need to download and process new content regularly
  • Apps that receive regular updates from external accessories

There is one other case, which is downloading in the background. This is a special case, though, because the app itself is still suspended and the download process is handed off to the system, in case the app has to be terminated by the system to reclaim resources.

What's not in the linked answer is notifications. Non-local notifications are generated on a server somewhere and pushed to the device via Apple Push Notifications (APN). The act of receiving a notification does not indicate the app itself did anything.

In your note example, when the note app transitions to the background, it is given a brief amount of time to save state. If it's in the process of doing something like saving a note, and it cannot complete it in the time allowed, it can ask for an extension, essentially, and then notify the system when it's done so the app can be suspended. This type of background work can be used by any app, not just those that fall under the categories listed above.

  • Great answer... it seems that iOS tracks user habits with apps to schedule BAR intervals most efficiently with app use, wifi connectivity, battery life. I imagine that if you use an app a lot, it will be given more BAR activity. So the answer is that app run state doesn't matter. Related question discussing BAR intervals: apple.stackexchange.com/questions/104572/… – y3sh Oct 13 '16 at 20:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .