---
title: "init(service:targetQueue:options:requirement:incomingSessionHandler:)"
framework: xpc
role: symbol
role_heading: Initializer
path: "xpc/xpclistener/init(service:targetqueue:options:requirement:incomingsessionhandler:)"
---

# init(service:targetQueue:options:requirement:incomingSessionHandler:)

Creates a listener with the service defined by the provided name, and requires that the session peer has the specified requirement.

## Declaration

```swift
@preconcurrency convenience init(service: String, targetQueue: DispatchQueue? = nil, options: XPCListener.InitializationOptions = .none, requirement: XPCPeerRequirement, incomingSessionHandler: @escaping @Sendable (XPCListener.IncomingSessionRequest) -> XPCListener.IncomingSessionRequest.Decision) throws
```

## Discussion

Discussion service: The Mach service or XPC Service name to create the listener with. requirement: The requirement the peer must have note: For a listener, requests that do not satisfy the requirement are dropped.
