<!--
{
  "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/BGTaskScheduler/register(forTaskWithIdentifier:using:launchHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Background Tasks"
    ],
    "preciseIdentifier" : "c:objc(cs)BGTaskScheduler(im)registerForTaskWithIdentifier:usingQueue:launchHandler:"
  },
  "title" : "register(forTaskWithIdentifier:using:launchHandler:)"
}
-->

# register(forTaskWithIdentifier:using:launchHandler:)

Register a launch handler for the task with the associated identifier that’s executed on the specified queue.

```
func register(forTaskWithIdentifier identifier: String, using queue: dispatch_queue_t?, launchHandler: @escaping (BGTask) -> Void) -> Bool
```

## Parameters

`identifier`

A string containing the identifier of the task.

`queue`

A queue for executing the task. Pass `nil` to use a default background queue.

`launchHandler`

The system runs the block of code for the launch handler when it launches the app in the background. The block takes a single parameter, a [`BGTask`](/documentation/BackgroundTasks/BGTask) object used for assigning an expiration handler and for setting a completion status. The block has no return value.

## Return value

Returns <doc://com.apple.documentation/documentation/Swift/true> if the launch handler was registered. Returns <doc://com.apple.documentation/documentation/Swift/false> if the identifier isn’t included in the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/BGTaskSchedulerPermittedIdentifiers> `Info.plist`.

## Discussion

Every identifier in the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/BGTaskSchedulerPermittedIdentifiers> requires a handler. Registration of all launch handlers must be complete before the end of <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/applicationDidFinishLaunching(_:)>.

> Important: Register each task identifier only once. The system kills the app on the second registration of the same task identifier.

---

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)