---
title: "submitTaskRequest(_:completionHandler:)"
framework: backgroundtasks
role: symbol
role_heading: Instance Method
path: "backgroundtasks/bgtaskscheduler/submittaskrequest(_:completionhandler:)"
---

# submitTaskRequest(_:completionHandler:)

Submits a background task request to be scheduled with a completion handler.

## Declaration

```swift
func submitTaskRequest(_ taskRequest: BGTaskRequest, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func submitTaskRequest(_ taskRequest: BGTaskRequest) async throws
```

## Parameters

- `taskRequest`: The task request object representing the parameters of the background task to be scheduled.
- `completionHandler`: A block that is called when submission completes. The block receives an optional error parameter: nil if the task was submitted successfully An NSError if submission failed

## Discussion

Discussion This method asynchronously submits the task request and invokes the completion handler with any errors that occur during submission. Submitting a task request for an unexecuted task that’s already in the queue replaces the previous task request. There can be a total of 1 refresh task and 10 processing tasks scheduled at any time. Trying to schedule more tasks will result in an error with code BGTaskScheduler.Error.Code.tooManyPendingTaskRequests. Common errors include: BGTaskScheduler.Error.Code.notPermitted: Task identifier not permitted or unsupported resources requested BGTaskScheduler.Error.Code.tooManyPendingTaskRequests: Too many pending tasks of this type BGTaskScheduler.Error.Code.unavailable: Background refresh disabled or app not permitted BGTaskScheduler.Error.Code.immediateRunIneligible: Immediate run not eligible due to system conditions The completion handler is called on an arbitrary queue. note: The completion handler may be invoked on a arbitrary queue after an arbitrary amount of delay. Do not call this method from the main thread or performance-critical contexts. This method replaces the deprecated submit(_:) method
