<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaDevice",
  "identifier" : "/documentation/MediaDevice/MediaDeviceExtension/activateDevice(_:session:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Device"
    ],
    "preciseIdentifier" : "s:11MediaDevice0aB9ExtensionP08activateB0_7session3foryAA0a6OutputB0V_AA0aG7SessionCAH12CapabilitiesVtF"
  },
  "title" : "activateDevice(_:session:for:)"
}
-->

# activateDevice(_:session:for:)

Called when the user activates a device via a user interface.

```
@MainActor func activateDevice(_ device: MediaOutputDevice, session: MediaOutputSession, for deviceFeatures: MediaOutputDevice.Capabilities)
```

## Parameters

`device`

The device to activate.

`session`

The session associated with the activation.

`deviceFeatures`

The capabilities requested for this activation.

## Discussion

If the device requires additional user authentication, call [`requestPairingCode(for:session:reason:authorizationMethod:)`](/documentation/MediaDevice/MediaDeviceRoutingManager/requestPairingCode(for:session:reason:authorizationMethod:)).
The system will report user input via [`connectUsingPairingCode(_:to:session:)`](/documentation/MediaDevice/MediaDeviceExtension/connectUsingPairingCode(_:to:session:)).

If the authorization fails, or the connection to the device fails, call [`failedToActivateDevice(_:session:error:)`](/documentation/MediaDevice/MediaDeviceRoutingManager/failedToActivateDevice(_:session:error:)).

If the activation is successful, call [`activatedDevice(_:session:)`](/documentation/MediaDevice/MediaDeviceRoutingManager/activatedDevice(_:session:)).

> Note: Once a device is activated, the extension will be restricted on the local area network and will only be permitted to connect
> to the device(s) that were activated as defined by the ``doc://com.apple.mediadevice/documentation/MediaDevice/MediaOutputDevice/networkEndpoints`` property.  Additionally
> upon device activation, your extension will lose access to Bluetooth and be granted access to reach out to the internet domains that
> have been declared in the ``MDRequestedDomains`` of the extension’s Info.plist

## Declaring Domains

Declare the domains your extension may need to connect to in your extension’s Info.plist using
`MDRequestedDomains`. The type must conform to an array of strings:

```xml
<key>EXAppExtensionAttributes</key>
<dict>
    <key>MDRequestedDomains</key>
        <array>
            <string>https://www.apple.com</string>
            <string>https://www.icloud.com</string>
        </array>
</dict>
```

## Grouping

If the extension receives multiple activations, then the associated [`MediaOutputDevice`](/documentation/MediaDevice/MediaOutputDevice) instances should be grouped together.
If the devices are already members of a group, then those groups should now be considered grouped together.
[`updateDevices(_:)`](/documentation/MediaDevice/MediaDeviceRoutingManager/updateDevices(_:)) should be called to update the state of group information.

---

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)