---
title: "connectUsingPairingCode(_:to:session:)"
framework: mediadevice
role: symbol
role_heading: Instance Method
path: "mediadevice/mediadeviceextension/connectusingpairingcode(_:to:session:)"
---

# connectUsingPairingCode(_:to:session:)

Called after the user has input their authorization into a user interface. Use the Security framework’s keychain to store any derived key material.

## Declaration

```swift
@MainActor func connectUsingPairingCode(_ pairingCode: String?, to device: MediaOutputDevice, session: MediaOutputSession)
```

## Parameters

- `pairingCode`: The PIN code or password entered by the user. May be nil if the user canceled the pairing process.
- `device`: The device that the pairing response is for.
- `session`: The session associated with the pairing request.

## Mentioned in

Creating a media device extension
