<!--
{
  "availability" : [
    "iOS: 27.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AccessoryTransportExtension",
  "identifier" : "/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Accessory Transport Extension"
    ],
    "preciseIdentifier" : "s:27AccessoryTransportExtension0A21FeatureSessionHandlerP"
  },
  "title" : "AccessoryFeatureSessionHandler"
}
-->

# AccessoryFeatureSessionHandler

A protocol that receives events from a data provider extension’s feature session.

```
protocol AccessoryFeatureSessionHandler<Session> : Sendable
```

## Overview

Conform to this protocol in your data provider extension to respond to the [`AccessoryFeatureSession`](/documentation/AccessoryTransportExtension/AccessoryFeatureSession) life cycle and incoming data. The system creates an instance of your type from the handler factory closure you provide when you declare the feature. Pass the closure to [`init(_:)`](/documentation/AccessoryTransportExtension/AccessoryWorker/init(_:)) once for each session that starts.

A handler that serves one feature can’t serve another because each feature pins the `Session` associated type through its own `Handler` type alias (for example, [`AccessoryWorker.Handler`](/documentation/AccessoryTransportExtension/AccessoryWorker/Handler)).

Implement [`sessionStarted(_:)`](/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler/sessionStarted(_:)) to hold the session weakly, and implement [`dataReceived(_:)`](/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler/dataReceived(_:)) to process data that the transport extension sends.

## Topics

### Handling the session life cycle

[`func sessionStarted(Self.Session)`](/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler/sessionStarted(_:))

Notifies the handler when its feature session starts.

[`func sessionInvalidated(error: (any Error)?)`](/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler/sessionInvalidated(error:))

Notifies the handler when its feature session ends.

### Receiving data

[`func dataReceived(Data) async throws`](/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler/dataReceived(_:))

Handles data that the transport extension sends.

### Associated Types

[`associatedtype Session : AccessoryFeatureSession`](/documentation/AccessoryTransportExtension/AccessoryFeatureSessionHandler/Session)

A session type that the handler serves.

## Relationships

### Inherits From

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)