<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BackgroundTasks",
  "identifier" : "/documentation/BackgroundTasks/BGTask",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Background Tasks"
    ],
    "preciseIdentifier" : "c:objc(cs)BGTask"
  },
  "title" : "BGTask"
}
-->

# BGTask

An abstract class for the framework’s tasks.

```
class BGTask
```

## Overview

With the exception of [`BGContinuedProcessingTask`](/documentation/BackgroundTasks/BGContinuedProcessingTask), which your app executes in the foreground, the system executes [`BGTask`](/documentation/BackgroundTasks/BGTask) subclasses on behalf of your app, while your app is in the background.

## Topics

### Reading Task Information

[`identifier`](/documentation/BackgroundTasks/BGTask/identifier)

The string identifier of the task.

### Configuring a Task

[`expirationHandler`](/documentation/BackgroundTasks/BGTask/expirationHandler)

A handler called shortly before the task’s background time expires.

[`-  setTaskCompletedWithSuccess:`](/documentation/BackgroundTasks/BGTask/setTaskCompleted(success:))

Informs the background task scheduler that the task is complete.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

### Inherited By

[`BGAppRefreshTask`](/documentation/BackgroundTasks/BGAppRefreshTask)

[`BGContinuedProcessingTask`](/documentation/BackgroundTasks/BGContinuedProcessingTask)

[`BGProcessingTask`](/documentation/BackgroundTasks/BGProcessingTask)

---

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)