---
title: "setTaskCompleted(success:)"
framework: backgroundtasks
role: symbol
role_heading: Instance Method
path: "backgroundtasks/bgtask/settaskcompleted(success:)"
---

# setTaskCompleted(success:)

Informs the background task scheduler that the task is complete.

## Declaration

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

## Parameters

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

## Mentioned in

Choosing Background Strategies for Your App

## Discussion

Discussion Not calling 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.

## See Also

### Configuring a Task

- [expirationHandler](backgroundtasks/bgtask/expirationhandler.md)
