Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Background Processing

ASecurity

Schedules and executes iOS background work with BGTaskScheduler and background URLSession. Use for app refresh, processing, continued-processing tasks, expiration and completion handling, background downloads, background pushes, registration, Info.plist configuration, or launch simulation.

3 stars
0 votes
0 copies
0 views
Added 9/28/2026
developmentswiftdebuggingapidatabasedocumentation

Works with

api

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add thiennc-tesoglobal/ios-skills --skill background-processing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Background Processing?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Background Processing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thiennc-tesoglobal-background-processing/badge)](https://www.skillsdirectory.com/skills/thiennc-tesoglobal-background-processing)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: background-processing
description: "Schedules and executes iOS background work with BGTaskScheduler and background URLSession. Use for app refresh, processing, continued-processing tasks, expiration and completion handling, background downloads, background pushes, registration, Info.plist configuration, or launch simulation."
---

# Background Processing

Register, schedule, and execute background tasks on iOS using BackgroundTasks (`BGTaskScheduler`), background `URLSession`, and background push notifications. Targets Swift 6.3 / iOS 26+.

## Contents

- [Capabilities and Configuration](#capabilities-and-configuration)
- [Task Selection Matrix](#task-selection-matrix)
- [Core Lifecycle Rules](#core-lifecycle-rules)
- [Route by Task](#route-by-task)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)

## Capabilities and 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>
<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>       <!-- Required for BGAppRefreshTask -->
    <string>processing</string>  <!-- Required for BGProcessingTask -->
    <string>remote-notification</string> <!-- Required for silent push -->
</array>
```

In Xcode: Target > Signing & Capabilities > Background Modes > enable **Background fetch**, **Background processing**, or **Remote notifications**.

## Task Selection Matrix

| Task Type | Max Duration | Trigger | Requires Power/Network | Use Case |
|---|---|---|---|---|
| `BGAppRefreshTask` | ~30 seconds | System opportunistic | Configurable hint | Light feed/state updates |
| `BGProcessingTask` | Several minutes | Device idle | External power / network optional | Database cleanup, maintenance, ML indexing |
| `BGContinuedProcessingTask` | User bounded | Foreground user action | Live Activity progress | Exporting large media, offline bundle generation |
| `URLSession.background` | Managed out-of-process | Network completion | Cellular/WiFi policy | Large file downloads and uploads |
| Silent Remote Push | ~30 seconds | APNs trigger (`content-available: 1`) | Network required | Server-driven data invalidation hint |

## Core Lifecycle Rules

1. **Register before launch finishes**: Register all handlers in `application(_:didFinishLaunchingWithOptions:)` (UIKit) or `App.init()` (SwiftUI). Submitting an unregistered identifier throws runtime exceptions.
2. **Re-schedule inside handler**: Immediately schedule the next iteration at the beginning of the execution handler so scheduling survives app crashes or task timeouts.
3. **Always set `expirationHandler`**: The system can revoke background execution time at any moment. The expiration handler must cancel active tasks and call `setTaskCompleted(success: false)`.
4. **Call `setTaskCompleted(success:)` exactly once**: Failing to call completion causes the system to penalize future execution allocations.
5. **Treat `earliestBeginDate` as a lower bound**: iOS determines actual launch time based on battery status, power state, and user interaction patterns.

## Route by Task

- For full registration code, canonical handlers, and checkpointing, read [Canonical Registration and Handlers](references/background-task-patterns.md#canonical-bgtaskscheduler-registration).
- For simulating task launches with LLDB (`_simulateLaunchForTaskWithIdentifier:`), read [Debugging Background Tasks](references/background-task-patterns.md#debugging-background-tasks).
- For background downloads, uploads, and handling app relaunch in `handleEventsForBackgroundURLSession`, read [Background URLSession Extended Patterns](references/background-task-patterns.md#background-urlsession--extended-patterns).
- For background push throttling and payload constraints, read [Background Push Extended Patterns](references/background-task-patterns.md#background-push--extended-patterns).
- For continued processing tasks conforming to `ProgressReporting`, read [BGContinuedProcessingTask Patterns](references/background-task-patterns.md#bgcontinuedprocessingtask--extended-patterns).

## Common Mistakes

- Submitting a task identifier that is not declared in `BGTaskSchedulerPermittedIdentifiers` (throws `.notPermitted`).
- Forgetting to call `task.setTaskCompleted(success:)` on all execution and failure paths.
- Omitting `task.expirationHandler`, leading to watchdog termination when background time expires.
- Scheduling app refresh at aggressive minute-scale intervals instead of respecting system heuristics.
- Using async/await convenience APIs or completion closures on background `URLSession` (requires delegate).

## Review Checklist

- [ ] Task identifiers declared in `BGTaskSchedulerPermittedIdentifiers`
- [ ] Required `UIBackgroundModes` enabled (`fetch`, `processing`, `remote-notification`)
- [ ] Handlers registered during app launch before launch completes
- [ ] `expirationHandler` cancels active tasks and reports failure
- [ ] `setTaskCompleted(success:)` called exactly once on all code paths
- [ ] Subsequent tasks re-scheduled within the handler
- [ ] Background `URLSession` uses delegate and preserves background completion handler
- [ ] Downloaded files moved in `urlSession(_:downloadTask:didFinishDownloadingTo:)` before return
- [ ] Silent pushes include `content-available: 1`, `apns-push-type: background`, and priority 5

## References

- [Background task patterns and debugging recipes](references/background-task-patterns.md)
- [BGTaskScheduler](https://sosumi.ai/documentation/backgroundtasks/bgtaskscheduler)
- [BGAppRefreshTask](https://sosumi.ai/documentation/backgroundtasks/bgapprefreshtask)
- [BGProcessingTask](https://sosumi.ai/documentation/backgroundtasks/bgprocessingtask)
- [BGContinuedProcessingTask](https://sosumi.ai/documentation/backgroundtasks/bgcontinuedprocessingtask)
- [Performing long-running tasks on iOS and iPadOS](https://sosumi.ai/documentation/backgroundtasks/performing-long-running-tasks-on-ios-and-ipados)

Attribution

thiennc-tesoglobalthiennc-tesoglobal
View sourceMore from thiennc-tesoglobal →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284972 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10311 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →