<!--
{
  "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/setTaskCompleted(success:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Background Tasks"
    ],
    "preciseIdentifier" : "c:objc(cs)BGTask(im)setTaskCompletedWithSuccess:"
  },
  "title" : "setTaskCompleted(success:)"
}
-->

# setTaskCompleted(success:)

Informs the background task scheduler that the task is complete.

```
func setTaskCompleted(success: Bool)
```

## Parameters

`success`

A `Boolean` indicating if the task completed successfully or not.

## Discussion

Not calling [`setTaskCompleted(success:)`](/documentation/BackgroundTasks/BGTask/setTaskCompleted(success:)) before the time for the task expires may result in the system killing your app.

You can reschedule an unsuccessful required task.

> Important: If you don’t set an expiration handler, the system will mark your task as complete and unsuccessful instead of sending a warning.

---

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)