Annual Defect Report 2026Download
Blog & Reports
How-to guide5 min read

How to Test App Backgrounding and Background Modes on iOS

Test iOS app backgrounding: lifecycle states, Background Modes, BGTaskScheduler tasks and Background App Refresh, with steps to trigger each on a device.

Short answer: Background App Refresh is iOS's name for an app's ability to open in the background to perform refresh tasks. People can turn it off, and it's restricted under some device management (Apple: backgroundRefreshStatus). Low Power Mode also pauses discretionary and background activities (Apple: isLowPowerModeEnabled). To test backgrounding, push your app into each state on purpose:

  • Background → suspended: swipe up to Home, or switch to another app.
  • Return from background: reopen the app from the app switcher, or with a notification or a link.
  • Termination while in the background: open other heavy apps until iOS reclaims your app, then relaunch it.
  • Low Power Mode: turn it on and confirm your app copes when background activity is paused.
  • Background tasks: on a device, trigger a BGTaskScheduler task from the debugger with Apple's _simulateLaunchForTaskWithIdentifier command (below).

What happens to an app when it goes to the background?

For scene-based apps, UIKit tracks each scene's state (Apple: Managing your app's life cycle):

State What it means What to test
Unattached Scene created or disconnected Cold launch restores the right screen
Foreground active Onscreen and receiving input Normal use
Foreground inactive Onscreen but interrupted, such as by a call or Control Center Timers and media pause correctly
Background Off screen and briefly running Data saved; shared resources released
Suspended In memory, not running Resume continues the session

UIKit can disconnect a background or suspended scene at any time to reclaim resources, which puts it back in the unattached state. Your restore path needs its own tests.

Two rules from Apple to turn into test cases (Apple: Preparing your UI to run in the background):

  • Release shared resources. If an app keeps using something like the camera after it goes to the background, the system terminates it. Test with the camera open, then swipe Home.
  • Hide sensitive data from the app-switcher snapshot. UIKit takes a snapshot of your UI when the app goes to the background. Open the app switcher on a screen that shows a password or a card number, and confirm that information is hidden.

What background modes are available on iOS?

Turn these on under Signing & Capabilities > Background Modes. Xcode adds the UIBackgroundModes array to Info.plist (Apple: Configuring background execution modes). The iOS modes include:

Mode UIBackgroundModes value Test that…
Audio, AirPlay and Picture in Picture audio Playback continues when locked or in the background
Location updates location Updates continue as designed after backgrounding
Voice over IP voip Incoming calls work with the app in the background
External accessory communication external-accessory Accessory data keeps flowing
Uses Bluetooth LE accessories bluetooth-central Accessory events arrive in the background
Acts as a Bluetooth LE accessory bluetooth-peripheral Peripheral mode keeps working
Background fetch fetch Content refreshes, and the app handles refresh being turned off
Remote notifications remote-notification A background push triggers a content download
Background processing processing BGProcessingTask work completes or cleans up
Push to Talk push-to-talk Audio starts from a push

Only turn on the modes you use, and test each one you turn on.

How do I trigger a BGTaskScheduler task for testing?

A background process in iOS is work your app does while it isn't on screen. Apple notes that an app in the background is typically suspended, so background modes and scheduled background tasks are the ways to keep working (Apple).

The system can take many hours to launch a scheduled task, so Apple provides two debugger commands for development. They work only on devices and use private functions. Never include them in an App Store build (Apple: Starting and terminating tasks during development).

Before you start, register each task identifier in BGTaskSchedulerPermittedIdentifiers in Info.plist (Apple). App refresh tasks need the fetch mode, and processing tasks need the processing mode.

Launch a task

  1. Set a breakpoint just after your submit(_:) call succeeds.
  2. Run on a device until the breakpoint pauses the app.
  3. In LLDB, run the following command, with your own identifier:

e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"TASK_IDENTIFIER"]

  1. Resume. The system calls your task's launch handler.

Force early termination

  1. Set a breakpoint inside the task, and launch it as above.
  2. When the app pauses there, run the following command, then resume. Your expiration handler should run and clean up.

e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateExpirationForTaskWithIdentifier:@"TASK_IDENTIFIER"]

How do you test network calls when the app resumes?

  • Start a request, then swipe Home before it finishes. On return, the screen shows the result or retries without duplicating it.
  • Background the app on Wi-Fi and return on cellular, or with no network.
  • Leave the app suspended long enough for a session token to expire. The return should refresh the token or prompt sign-in, not show a broken screen.
  • Return through a push notification or a link, not only from the app switcher. See push notification testing.

Why does my app get killed in the background?

Common causes:

  • It used too much memory compared with other apps, so the system reclaimed it.
  • It held a shared resource, such as the camera, after going to the background.
  • A background task didn't finish before its expiration handler ran.

The person may also have closed it from the app switcher. Each case should end in a clean cold launch, with no lost data and no crash. Test it on purpose: background the app mid-task, open several heavy apps, then relaunch.

How does Mobot test app backgrounding?

Mobot's physical robots use real iPhones and Android phones the way a person does. They swipe Home, switch apps, open notifications and come back. Mobot AI and Mobot's team build your test cases around the screens where an interruption matters, such as checkout, sign-in, uploads and media. Defect reports include device screenshots of the state before and after the switch.

FAQ

What is Background App Refresh? It's an app's ability to open in the background to perform refresh tasks. People can turn it off, it can be restricted, and Low Power Mode pauses discretionary and background activities (Apple: isLowPowerModeEnabled).

How do I trigger a BGTaskScheduler task for testing? On a device, pause in the debugger after submit(_:) succeeds and run Apple's _simulateLaunchForTaskWithIdentifier LLDB command with your task identifier, then resume. Use _simulateExpirationForTaskWithIdentifier to test the expiration handler. These are private and for development only.

What background modes are available on iOS? They include audio, location, voip, external-accessory, bluetooth-central, bluetooth-peripheral, fetch, remote-notification, processing and push-to-talk, set through Signing & Capabilities > Background Modes.

Why does my app get killed in the background? Usually because of memory pressure, holding a shared resource such as the camera, or a background task that didn't finish before expiration. Test cold relaunch after each.

Test backgrounding and interruptions on real devices.

Start free trial (1,000 credits)or talk to sales →
How-to

See What Your Emulators Are Missing

Get a real, verified defect report from Mobot’s robots and QA analysts — on your app, on real devices.

or talk to sales