DDDevicePickerViewController
A UIKit view that displays other devices on the network, and creates an encrypted connection to a copy of your app running on that device.
Declaration
class DDDevicePickerViewControllerMentioned in
Overview
Always display the device picker as a full-screen, modal view. If the user selects a device, the system sets the endpoint property and calls the endpointPickedHandler.
// This example uses the default application services parameters;
// however, you can add a `NWProtocolFramer` to provide application-level messaging.
let parameters = NWParameters.applicationService
// Create the view controller for the endpoint picker.
let devicePickerController =
DDDevicePickerViewController(browseDescriptor: NWBrowser.Descriptor.applicationService(name: "MyAppService"),
parameters: parameters)
// Show the network device picker as a full-screen, modal view.
devicePickerController.modalTransitionStyle = .coverVertical
show(devicePickerController, sender: nil)
let endpoint: NWEndpoint
do {
endpoint = try await devicePickerController.endpoint
} catch {
// A person canceled the endpoint picker view.
return
}
// Use the endpoint here.
myDeviceConnectionManager.connectTo(endpoint: endpoint)