
Background Processing
Register BGTaskScheduler tasks, background URLSession, and push-driven work on iOS without missing Info.plist rules or expiration handling.
Install
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill background-processingWhat is this skill?
- Covers BGAppRefreshTask, BGProcessingTask, and BGContinuedProcessingTask (iOS 26+)
- Info.plist BGTaskSchedulerPermittedIdentifiers setup and notPermitted error avoidance
- Background URLSession downloads and background push notification triggers
- Expiration handling, task completion, and simulated-launch debugging patterns
- Review checklist plus common mistakes section for App Store–ready background work
Adoption & trust: 1.7k installs on skills.sh; 713 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Vercel React Native Skillsvercel-labs/agent-skills
Firebase Basicsfirebase/agent-skills
Building Native Uiexpo/skills
Firebase Ai Logic Basicsfirebase/agent-skills
Native Data Fetchingexpo/skills
Firebase Firestorefirebase/agent-skills
Journey fit
Common Questions / FAQ
Is Background Processing safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Background Processing
# Background Processing Register, schedule, and execute background work on iOS using the BackgroundTasks framework, background URLSession, and background push notifications. ## Contents - [Info.plist Configuration](#infoplist-configuration) - [BGTaskScheduler Registration](#bgtaskscheduler-registration) - [BGAppRefreshTask Patterns](#bgapprefreshtask-patterns) - [BGProcessingTask Patterns](#bgprocessingtask-patterns) - [BGContinuedProcessingTask (iOS 26+)](#bgcontinuedprocessingtask-ios-26) - [Background URLSession Downloads](#background-urlsession-downloads) - [Background Push Triggers](#background-push-triggers) - [Common Mistakes](#common-mistakes) - [Review Checklist](#review-checklist) - [References](#references) ## Info.plist Configuration Every task identifier **must** be declared in `Info.plist` under `BGTaskSchedulerPermittedIdentifiers`, or `submit(_:)` throws `BGTaskScheduler.Error.Code.notPermitted`. ```xml <key>BGTaskSchedulerPermittedIdentifiers</key> <array> <string>com.example.app.refresh</string> <string>com.example.app.db-cleanup</string> <string>com.example.app.export</string> </array> ``` Also enable the required `UIBackgroundModes`: ```xml <key>UIBackgroundModes</key> <array> <string>fetch</string> <!-- Required for BGAppRefreshTask --> <string>processing</string> <!-- Required for BGProcessingTask --> </array> ``` 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 the `App` initializer. ### UIKit Registration ```swift import BackgroundTasks @main class AppDelegate: UIResponder, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { BGTaskScheduler.shared.register( forTaskWithIdentifier: "com.example.app.refresh", using: nil // nil = default background queue ) { task in self.handleAppRefresh(task: task as! BGAppRefreshTask) } BGTaskScheduler.shared.register( forTaskWithIdentifier: "com.example.app.db-cleanup", using: nil ) { task in self.handleDatabaseCleanup(task: task as! BGProcessingTask) } return true } } ``` ### SwiftUI Registration ```swift import SwiftUI import BackgroundTasks @main struct MyApp: App { init() { BGTaskScheduler.shared.register( forTaskWithIdentifier: "com.example.app.refresh", using: nil ) { task in BackgroundTaskManager.shared.handleAppRefresh( task: task as! BGAppRefreshTask ) } } var body: some Scene { WindowGroup { ContentView() } } } ``` ## BGAppRefreshTask Patterns Short-lived tasks (~30 seconds) for fetching small data updates. The system decides when to launch based on usage patterns. ```swift func scheduleAppRefresh() { let request = BGAppRefreshTaskRequest( identifier: "com.example.app.refresh" ) request.earliestBeginDate = Date(timeIntervalSinceNow: 15 * 60) do { try BGTaskScheduler.shared.submit(request) } catch { print("Could not schedule app refresh: \(error)") }