<!--
{
  "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:)-8rodk",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC11XPCListenerC22IncomingSessionRequestC6accept22incomingMessageHandler012cancellationI0AE8DecisionVAA13XPCDictionaryVSgALc_yAA12XPCRichErrorVcSgtF"
  },
  "title" : "accept(incomingMessageHandler:cancellationHandler:)"
}
-->

# accept(incomingMessageHandler:cancellationHandler:)

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

```
@preconcurrency func accept(incomingMessageHandler: @escaping @Sendable (XPCDictionary) -> XPCDictionary?, cancellationHandler: (@Sendable (XPCRichError) -> Void)? = nil) -> XPCListener.IncomingSessionRequest.Decision
```

## 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.

## Discussion

If you need to perform additional configuration on the session, use [`accept(incomingMessageHandler:cancellationHandler:)`](/documentation/XPC/XPCListener/IncomingSessionRequest/accept(incomingMessageHandler:cancellationHandler:)-48c3k) instead; that version returns a tuple that contains the 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)