Background Processing
Register, schedule, and execute background work on iOS using the BackgroundTasks framework, background URLSession, and background push notifications.
Contents
- Info.plist Configuration
- BGTaskScheduler Registration
- BGAppRefreshTask Patterns
- BGProcessingTask Patterns
- BGContinuedProcessingTask (iOS 26+)
- Background URLSession Downloads
- Background Push Triggers
- Common Mistakes
- Review Checklist
- References
Info.plist Configuration
Every task identifier must be declared in Info.plist under
BGTaskSchedulerPermittedIdentifiers, or submit(_:) throws
BGTaskScheduler.Error.Code.notPermitted.
Also enable the required UIBackgroundModes:
In Xcode: target > Signing & Capabilities > Background Modes > enable "Background fetch" and "Background processing".
BGTaskScheduler Registration
Register handlers before app launch completes. In UIKit, register in
application(_:didFinishLaunchingWithOptions:); in SwiftUI, register in App.init().
UIKit Registration
SwiftUI Registration
BGAppRefreshTask Patterns
Short-lived tasks (~30 seconds) for fetching small data updates. The system
decides when to launch; earliestBeginDate is only a lower-bound hint.
BGProcessingTask Patterns
Long-running tasks (minutes) for maintenance, data processing, or cleanup.
They run while the device is idle and can require external power; the same
earliestBeginDate lower-bound rule applies.
BGContinuedProcessingTask (iOS 26+)
A task initiated in the foreground by a user action that continues running in the
background. The system displays progress via a Live Activity. Conforms to
ProgressReporting.
Availability: iOS 26.0+, iPadOS 26.0+
Unlike BGAppRefreshTask and BGProcessingTask, this task starts immediately
from the foreground. The system can terminate it under resource pressure,
prioritizing tasks that report minimal progress first. Set expirationHandler for user or system cancellation, cancel in-flight work, and clean up partial output before reporting completion.
For GPU work, check support and enable Background GPU Access (com.apple.developer.background-tasks.continued-processing.gpu):
Background URLSession Downloads
Use URLSessionConfiguration.background for downloads that continue even after
the app is suspended or terminated. The system handles the transfer out of
process.
Handle app relaunch — store and invoke the system completion handler:
Background Push Triggers
Silent push notifications wake your app briefly to fetch new content. Set
content-available: 1 in the push payload.
Send the APNs request with apns-push-type: background and
apns-priority: 5. Background push delivery is low priority and not
guaranteed; keep sends infrequent, generally no more than two or three per
hour.
Handle in AppDelegate:
Enable "Remote notifications" in Background Modes and register:
Common Mistakes
1. Missing Info.plist identifiers
2. Not calling setTaskCompleted(success:)
Use the canonical app-refresh or processing handler above: every success, failure, and cancellation path reports completion exactly once.
3. Ignoring the expiration handler
Use the same canonical handler to cancel in-flight work and report failure from
expirationHandler.
4. Scheduling too frequently
The scheduling sections own the lower-bound rule. Avoid minute-scale refresh requests; the system still chooses actual launch time.
5. Over-relying on background time
Review Checklist
- All task identifiers listed in
BGTaskSchedulerPermittedIdentifiers - Required
UIBackgroundModesenabled (fetch,processing) - Tasks registered before app launch completes
-
setTaskCompleted(success:)called on every code path -
expirationHandlerset and cancels in-flight work - Next task scheduled inside the handler (re-schedule pattern)
-
earliestBeginDateuses reasonable intervals and is treated as a hint - Background URLSession uses delegate (not async/closures)
- Background URLSession file moved in
didFinishDownloadingTobefore return -
handleEventsForBackgroundURLSessionstores and calls completion handler - Background push payload includes
content-available: 1 - Background push APNs request uses
apns-push-type: backgroundandapns-priority: 5 -
fetchCompletionHandlercalled promptly with correct result - BGContinuedProcessingTask reports progress via
ProgressReporting - Work is incremental and cancellation-safe (
Task.checkCancellation()) - No blocking synchronous work in task handlers
References
- See references/background-task-patterns.md [blocked] for extended patterns, background URLSession edge cases, debugging with simulated launches, and background push best practices.
- BGTaskScheduler
- BGAppRefreshTask
- BGProcessingTask
- BGContinuedProcessingTask (iOS 26+)
- BGContinuedProcessingTaskRequest (iOS 26+)
- Using background tasks to update your app
- Performing long-running tasks on iOS and iPadOS


