<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVRouting",
  "identifier" : "/documentation/AVRouting/AVCustomRoutingControllerDelegate/customRoutingController(_:handle:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVRouting"
    ],
    "preciseIdentifier" : "c:objc(pl)AVCustomRoutingControllerDelegate(im)customRoutingController:handleEvent:completionHandler:"
  },
  "title" : "customRoutingController(_:handle:completionHandler:)"
}
-->

# customRoutingController(_:handle:completionHandler:)

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

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

```
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

> 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:
> 
> ```swift
> func customRoutingController(_ controller: AVCustomRoutingController, handle event: AVCustomRoutingEvent) async -> Bool
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

---

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)