ProximityDevice.DeviceId ProximityDevice.DeviceId ProximityDevice.DeviceId ProximityDevice.DeviceId ProximityDevice.DeviceId Property

Definition

Gets the DeviceInformation Id for a proximity device.

public : Platform::String DeviceId { get; }
winrt::hstring DeviceId();
public string DeviceId { get; }
Public ReadOnly Property DeviceId As string
var string = proximityDevice.deviceId;

Property Value

string string string

The DeviceInformation Id for a proximity device.

Additional features and requirements

Capabilities
ID_CAP_PROXIMITY [Windows Phone] proximity ID_CAP_PROXIMITY [Windows Phone]

Examples

private async void QueryDeviceProperties()
{
    // Include the proximity properties key
    var propertiesToRetrieve = new List<String> {"{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"};

    var defaultProximityDevice =
        Windows.Networking.Proximity.ProximityDevice.GetDefault();

    if (defaultProximityDevice != null)
    {
        var devInfo = await Windows.Devices.Enumeration.DeviceInformation.CreateFromIdAsync(
            defaultProximityDevice.DeviceId, propertiesToRetrieve);

        if (devInfo.Properties.ContainsKey("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"))
        {
            var proximityCapabilities =
                devInfo.Properties["{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"] as string[];
            if (proximityCapabilities.Contains("StandardNfc"))
            {
                // This proximity device supports NFC
            }
        }
    }
}
function queryDeviceProperties() {
    // Include the proximity properties key
    var propertiesToRetrieve = new Array();
    propertiesToRetrieve.push("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2");

    var defaultProximityDevice =
        Windows.Networking.Proximity.ProximityDevice.getDefault();

    if (defaultProximityDevice) {
        Windows.Devices.Enumeration.DeviceInformation.createFromIdAsync(
            defaultProximityDevice.deviceId, propertiesToRetrieve).done(
            function (devInfo) {
                if (devInfo.properties.hasKey("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2")) {
                    var proximityCapabilities = new Array();
                    proximityCapabilities = devInfo.properties["{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"];
                    for (var i = 0; i < proximityCapabilities.length; i++) {
                        if (proximityCapabilities[i] == "StandardNfc") {
                            // This proximity device supports NFC
                        }
                    };
                }
            });
    }
}
Private Async Sub QueryDeviceProperties()
    ' Include the proximity properties key
    Dim propertiesToRetrieve = New List(Of String) From {"{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"}

    Dim defaultProximityDevice =
        Windows.Networking.Proximity.ProximityDevice.GetDefault()

    If defaultProximityDevice IsNot Nothing Then
        Dim devInfo = Await Windows.Devices.Enumeration.DeviceInformation.CreateFromIdAsync(
            defaultProximityDevice.DeviceId, propertiesToRetrieve)

        If devInfo.Properties.ContainsKey("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2") Then
            Dim proximityCapabilities =
                TryCast(devInfo.Properties("{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2"), String())

            If proximityCapabilities.Contains("StandardNfc") Then
                ' This proximity device supports NFC
            End If
        End If
    End If
End Sub

Remarks

If your computer supports Proximity and has an NFC device installed, which is commonly the case, then the GetDefault method will return the device that supports NFC. You can also determine whether your computer has an NFC device installed by querying the device information for the property "{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2". In the DeviceInformation.Properties object returned from the query the value for the "{FB3842CD-9E2A-4F83-8FCC-4B0761139AE9} 2" key contains and array of strings that describe the capabilities of the proximity device. If one of the strings is "StandardNfc", then the device supports NFC protocols such as NDEF. For more information on how to query for the properties of a device, see How to retrieve additional properties for a device or PnP object.

See also