Contents

DevicePickerSupportedAction

An environment value that indicates whether the current device supports device discovery.

Declaration

struct DevicePickerSupportedAction

Overview

Access the action using the .devicePickerSupports key. Then call it as a function, passing the same browse descriptor and parameters you use to search for devices.

struct SettingsView: View {

    @Environment{\.devicePickerSupports} var myDevicePickerSupports
    @Binding var showDevicePicker: Bool

    var body: some View {
        if myDevicePickerSupports(.applicationService("MyAppService"),
                                  parameters: { .applicationService }) {
            Button("Select A Device") {
                // Display a device picker.
                showDevicePicker = true
            }
        }
    }
}

Topics

Checking for support

See Also

Pairing with nearby devices