One Logo Pool Ball
WiFiAware · IOS API REFERENCE

WAPublisherListener.Action

struct · iOS 26.0+ · SDK 27.1

struct Action

The structure that configures the Wi-Fi Aware publisher operation that the network listener performs. The configuration includes the service and devices it operates on. The ``WAPublisherListener/Action`` is the first component of the `.wifiAware()` instruction to a `NetworkListener`. The code below is an example of creating a `NetworkListener`: ```swift NetworkListener(for: .wifiAware( .connecting(to:service, from:.selected(devices)) ) ) ````

Members (2)

static · iOS 26.0+

connecting

TypeScript
static connecting(myPublishingService: WAPublishableService, pairedDevices: WAPublisherListener_Devices, wifiAware?: (WAPublisherListener_DatapathParameters) | null): WAPublisherListener_Action
Swift declaration
static func connecting(to myPublishingService: WAPublishableService, from pairedDevices: WAPublisherListener.Devices, datapath wifiAware: WAPublisherListener.DatapathParameters? = nil) -> WAPublisherListener.Action

Publishes the provided service over Wi-Fi, enabling connections from the specified paired devices. When publishing, the `NetworkListener` provides a `NetworkConnection` object for each paired device that connects. You can set the data path parameters, including the ``WAPerformanceMode``, in the optional "`datapath:`" parameter, or by using ``WAParameters`` that are written into the <doc://com.apple.documentation/documentation/Network/NWParameters> for the `NetworkListener`. > Important: Each service must have the same ``WAPerformanceMode`` on both the `NetworkBrowser` (subscriber) and `NetworkListener` (publisher) sides of the connection, or the resulting performance behavior is undefined. If not specified, the performance mode defaults to ``WAPerformanceMode/bulk`` on both sides. - Parameters: - myPublishingService: The service the publisher hosts, and accept connections to. - pairedDevices: The remote devices to accept connections from. The `NetworkListener` isn't activated if the system doesn't specify any devices. - wifiAware: The parameters specifying the initial Wi-Fi Aware data path configuration for any resulting connections, or `nil` to apply default parameters. - Returns: A new `Action` configuring this operation.

static · iOS 26.4+

addingConnections

TypeScript
static addingConnections(pairedDevices: WAPublisherListener_Devices): WAPublisherListener_Action
Swift declaration
static func addingConnections(from pairedDevices: WAPublisherListener.Devices) -> WAPublisherListener.Action

Make additional network connections over a preexisting Wi-Fi Aware datapath, without publishing or advertising any services over Wi-Fi Aware. Your app should setup it's first connection to a device using Wi-Fi Aware service discovery. Apps can do so by defining a single "control" service used for initial discovery and connection, and creating a `NetworkListener` for that service via ``connecting(to:from:datapath:)``. Subsequent connections may then use a `.addingConnections` `NetworkListener`to quickly connect without going through the service discovery process again. The listener will be limited to accepting connections from the paired devices specified. >Important: Your app must have at least one pre-existing ``Network/NetworkConnection`` to a remote device, before it can make additional connections to an `.addingConnections` `NetworkListener` on that device. Example Usage: ```swift // Create a listener to add new connections let listener = try NetworkListener(for: .wifiAware(.addingConnections(from: .matching(devices))), using: .parameters({ TCP() })) // Get the port number once the listener is in the ready state guard let port = listener.port { return } // Send the port number to the client device(s) over the control connection. ``` - Parameter pairedDevices: The remote devices to accept connections from. The `NetworkListener` isn't activated if the system doesn't specify any devices. - Returns: A new `Action` that configures the listener to accept network connections from specified paired devices.

Skipped declarations

No declarations were skipped in this snapshot.

All WiFiAware types →