<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCListener/IncomingSessionRequest/accept(incomingMessageHandler:cancellationHandler:)-56fch",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC11XPCListenerC22IncomingSessionRequestC6accept22incomingMessageHandler012cancellationI0AE8DecisionVSE_pSgxc_yAA12XPCRichErrorVcSgtSeRzlF"
  },
  "title" : "accept(incomingMessageHandler:cancellationHandler:)"
}
-->

# accept(incomingMessageHandler:cancellationHandler:)

Accepts an incoming session request from a client using closures to handle encodable messages or cancellation, and returns the inactive session.

```
@preconcurrency func accept<Message>(incomingMessageHandler: @escaping @Sendable (Message) -> (any Encodable)?, cancellationHandler: (@Sendable (XPCRichError) -> Void)? = nil) -> XPCListener.IncomingSessionRequest.Decision where Message : Decodable
```

## Parameters

`incomingMessageHandler`

A closure that receives incoming messages from a client.

`cancellationHandler`

An optional closure that the system invokes when it cancels the session.

## Return Value

A decision that indicates whether the listener accepts or rejects the incoming session.

---

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)