<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/BackgroundTask",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14BackgroundTaskV"
  },
  "title" : "BackgroundTask"
}
-->

# BackgroundTask

The kinds of background tasks that your app or extension can handle.

```
struct BackgroundTask<Request, Response>
```

## Overview

Use a value of this type with the [`backgroundTask(_:action:)`](/documentation/SwiftUI/Scene/backgroundTask(_:action:)) scene
modifier to create a handler for background tasks that the system sends
to your app or extension. For example, you can use [`urlSession`](/documentation/SwiftUI/BackgroundTask/urlSession) to define
an asynchronous closure that the system calls when it launches your app or
extension to handle a response from a background
<doc://com.apple.documentation/documentation/Foundation/URLSession>.

## Topics

### Refreshing the app

[`appRefresh(_:)`](/documentation/SwiftUI/BackgroundTask/appRefresh(_:))

A task that updates your app’s state in the background for a
matching identifier.

### Receiving connectivity updates

[`bluetoothAlert`](/documentation/SwiftUI/BackgroundTask/bluetoothAlert)

A background task used to receive critical alerts from paired
bluetooth accessories.

[`watchConnectivity`](/documentation/SwiftUI/BackgroundTask/watchConnectivity)

A background task used to receive background updates from the Watch
Connectivity framework.

### Responding to URL sessions

[`urlSession`](/documentation/SwiftUI/BackgroundTask/urlSession)

A task that responds to background URL sessions.

[`urlSession(_:)`](/documentation/SwiftUI/BackgroundTask/urlSession(_:))

A task that responds to background URL sessions matching the given
identifier.

[`urlSession(matching:)`](/documentation/SwiftUI/BackgroundTask/urlSession(matching:))

A task that responds to background URL sessions matching the given
predicate.

### Updating intents and shortcuts

[`intentDidRun`](/documentation/SwiftUI/BackgroundTask/intentDidRun)

A background task used to update your app after a SiriKit intent runs.

[`relevantShortcut`](/documentation/SwiftUI/BackgroundTask/relevantShortcut)

A background task used to periodically donate relevant Siri shortcuts.

### Processing tasks

[`processingTask(_:)`](/documentation/SwiftUI/BackgroundTask/processingTask(_:))

A task that processes tasks in the background.

### Deprecated symbols

[`appRefresh`](/documentation/SwiftUI/BackgroundTask/appRefresh)

A task that updates your app’s state in the background.

[`snapshot`](/documentation/SwiftUI/BackgroundTask/snapshot)

A background task used to update your app’s user interface in
preparation for a snapshot.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)