---
title: "customRoutingController(_:handle:completionHandler:)"
framework: avrouting
role: symbol
role_heading: Instance Method
path: "avrouting/avcustomroutingcontrollerdelegate/customroutingcontroller(_:handle:completionhandler:)"
---

# customRoutingController(_:handle:completionHandler:)

Connects to, or disconnects from, a device when a user requests it in the picker.

## Declaration

```swift
func customRoutingController(_ controller: AVCustomRoutingController, handle event: AVCustomRoutingEvent, completionHandler: @escaping @Sendable (Bool) -> Void)
```

```swift
func customRoutingController(_ controller: AVCustomRoutingController, handle event: AVCustomRoutingEvent) async -> Bool
```

## Parameters

- `controller`: A custom routing controller.
- `event`: The routing event to handle.
- `completionHandler`: A completion handler to call after processing the event. Pass doc://com.apple.documentation/documentation/Swift/true to the completion handler if the activation, reactivation, or deactivation of the route succeeds, and doc://com.apple.documentation/documentation/Swift/false, otherwise.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func customRoutingController(_ controller: AVCustomRoutingController, handle event: AVCustomRoutingEvent) async -> Bool For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Handling controller events

- [customRoutingController(_:eventDidTimeOut:)](avrouting/avcustomroutingcontrollerdelegate/customroutingcontroller(_:eventdidtimeout:).md)
- [customRoutingController(_:didSelect:)](avrouting/avcustomroutingcontrollerdelegate/customroutingcontroller(_:didselect:).md)
