BackgroundTasks — Foundations Skill
Purpose
Route BackgroundTasks implementation tasks to the minimum required
BackgroundTasks Knowledge Contracts. v1 scope is scheduling and running
deferred background work through BGTaskScheduler -- registration,
submission, execution, expiration handling, processing constraints, and
the hand-off point where background-refreshed data reaches a widget --
not BGContinuedProcessingTask, not legacy Background Fetch, not
unrelated background modes, and not URLSession background transfer.
Routing
Load only the contracts relevant to the task. All paths relative to knowledge/backgroundtasks/.
- Registering a task identifier with
BGTaskScheduler.shared.register(forTaskWithIdentifier:using:launchHandler:); declaringBGTaskSchedulerPermittedIdentifiers; choosingBGAppRefreshTaskRequestvsBGProcessingTaskRequest; submitting withsubmit(_:); or reasoning aboutearliestBeginDate-> background-task-registration-and-scheduling.md - Handling the
BGTaskdelivered to alaunchHandler(casting toBGAppRefreshTask/BGProcessingTask); settingexpirationHandler; callingsetTaskCompleted(success:); or re-submitting a request for the next occurrence -> task-execution-and-expiration-handling.md - Setting
BGProcessingTaskRequest.requiresNetworkConnectivity/requiresExternalPower; or deciding whether work belongs onBGProcessingTaskRequestversusBGAppRefreshTaskRequest-> processing-task-constraints-and-conditions.md - Scheduling a
BGAppRefreshTaskRequestto refresh data a widget depends on, up through the point new data has landed -> background-refresh-and-widget-timeline-hookup.md
Never load more than the contracts relevant to the specific question.
Stop Conditions
Stop and report if the requested topic has no matching Knowledge
Contract in knowledge/backgroundtasks/ — do not guess or fall back to
general knowledge. BGContinuedProcessingTask (foreground-initiated work
that can continue in the background) is out of scope entirely -- newer
API surface, deferred, not yet built (see docs/architecture/domain-map.md).
Legacy Background Fetch (UIApplication.setMinimumBackgroundFetchInterval,
application(_:performFetchWithCompletionHandler:)) is out of scope --
superseded by this framework, not planned as a separate domain; report
that explicitly. Other background modes unrelated to BGTaskScheduler
(background audio, background location, VoIP push/PushKit) are out of
scope entirely. URLSession background transfer configuration
(URLSessionConfiguration.background) is networking's job, not this
Skill's. Actually calling WidgetCenter.shared.reloadTimelines(ofKind:)/
reloadAllTimelines(), and every rule about the refresh budget governing
that call, is widgetkit's job (knowledge.widgetkit.timeline-reloading-and-refresh-budget)
-- this Skill only routes to getting the background task registered,
submitted, and run so fresh data exists for that call to reload.