background-processing
Schedule and execute background work on iOS using BGTaskScheduler. Use when registering BGAppRefreshTask for short background fetches, BGProcessingTask for long-running maintenance, BGContinuedProcessingTask (iOS 26+) for foreground-started work that continues in background, background URLSession downloads, or background push notifications. Covers Info.plist configuration, expiration handling, task completion, and debugging with simulated launches.
Security Assessment
About background-processing
This skill provides comprehensive guidance for implementing background processing on iOS using Apple's BackgroundTasks framework. It addresses the challenge of executing work when your app is not in the foreground, whether for periodic data refreshes, maintenance tasks, or continuing user-initiated operations. The skill covers the complete lifecycle from Info.plist configuration through task registration, scheduling, execution, and debugging.
The skill encompasses three main task types: BGAppRefreshTask for short background fetches (approximately 30 seconds), BGProcessingTask for longer maintenance operations, and BGContinuedProcessingTask (iOS 26+) for foreground-initiated work that continues in the background. It also covers background URLSession downloads and background push notifications. Each task type includes practical code examples showing proper registration patterns, expiration handling, and task completion.
This skill is essential for iOS developers building apps that need to sync data, perform housekeeping, or provide seamless user experiences across app lifecycle transitions. It targets developers working on apps with features like content feeds, messaging, data synchronization, media processing, or any scenario requiring work to continue when the app moves to the background. The skill emphasizes Info.plist requirements, proper registration timing in both UIKit and SwiftUI apps, and includes debugging techniques using simulated launches.
FAQ
When should I use BGAppRefreshTask versus BGProcessingTask?
Use BGAppRefreshTask for short tasks (around 30 seconds) that fetch small data updates, like checking for new messages or refreshing a feed. Use BGProcessingTask for longer maintenance operations like database cleanup, indexing, or processing large datasets. The system provides different runtime budgets for each.
What happens if I forget to declare task identifiers in Info.plist?
If you attempt to submit a task request with an identifier not listed under BGTaskSchedulerPermittedIdentifiers in Info.plist, the submit(_:) method will throw a BGTaskScheduler.Error.Code.notPermitted error and the task will not be scheduled.
When should I register my background task handlers?
You must register handlers before app launch completes. In UIKit apps, register them in application(_:didFinishLaunchingWithOptions:). In SwiftUI apps, register them in your App struct's init() method. Registering too late will prevent your handlers from being called.
Does BGContinuedProcessingTask work on all iOS versions?
No, BGContinuedProcessingTask is only available on iOS 26 and later. It is specifically designed for foreground-started work that needs to continue in the background. For earlier iOS versions, you must use BGAppRefreshTask or BGProcessingTask depending on your use case.
How reliable is the earliestBeginDate parameter?
The earliestBeginDate is only a lower-bound hint to the system. The system decides when to actually launch your task based on device usage patterns, power state, and other factors. Your task may run significantly later than the specified date, so don't rely on it for time-sensitive operations.
Install background-processing
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dpearson2699/swift-ios-skills