Instance Method


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: DispatchQueue?, launchHandler: @escaping (BGTask) -> Void) -> Bool



A string containing the identifier of the task.


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


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 object used for assigning an expiration handler and for setting a completion status. The block has no return value.

Return Value

Returns true if the launch handler was registered. Returns false if the identifier isn't included in the BGTaskSchedulerPermittedIdentifiers Info.plist.


Every identifier in the BGTaskSchedulerPermittedIdentifiers requires a handler. Registration of all launch handlers must be complete before the end of applicationDidFinishLaunching(_:).

See Also

Scheduling a Task

func submit(BGTaskRequest)

Submit a previously registered background task for execution.