One Logo Pool Ball
ExtensionFoundation · IOS API REFERENCE

ConnectionHandler

struct · iOS 26.0+ · SDK 27.1

@MainActor @preconcurrency struct ConnectionHandler

A type that contains a custom closure that handles incoming XPC connections. This type manages a closure in your app extension that accepts incoming XPC connections from a host app. Create an instance of this structure and initialize it with a closure for the type of XPC connection the host app uses with app extensions. Assign the instance you created to the ``AppExtension/configuration`` property of your custom ``AppExtension`` type. When the host app tries to open a connection, the system runs your closure to accept that connection. Use this type to establish connections with either the <doc://com.apple.documentation/documentation/foundation> or <doc://com.apple.documentation/documentation/xpc> framework.

Members (1)

method · iOS 26.0+

accept

TypeScript
accept(connection: _Foundation_NSXPCConnection): Promise<boolean>
Swift declaration
nonisolated func accept(connection: NSXPCConnection) -> Bool

Returns a Boolean value that indicates whether you accept an incoming connection request from the host app. - Parameters: - connection: A connection object you can use to communicate with the host app. - Returns: `true` if you accept the connection to the host app, or `false` if you don’t. Implement this method in your custom type and use it to establish communication between your app extension and the host app that made the request. To accept a connection request, set the connection’s <doc://com.apple.documentation/documentation/foundation/nsxpcconnection/exportedobject> property to an object in your app extension that implements a protocol or type from the host’s SDK. Similarly, put the type information in the <doc://com.apple.documentation/documentation/foundation/nsxpcconnection/exportedinterface> property. You can also retrieve other relevant properties of the connection object, such as the remote connection details, and use them to set up your app extension. When you’re ready to start communicating with the host, call the connection’s <doc://com.apple.documentation/documentation/foundation/nsxpcconnection/resume()> method and then return `true` from this method.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ConnectionHandler.init(onSessionRequest:)

callback cannot propagate synchronous failure

ConnectionHandler.init(onConnection:)

callback cannot propagate synchronous failure

All ExtensionFoundation types →