Поделиться через


UserConsentVerifier.CheckAvailabilityAsync Метод

Определение

Проверяет, доступно ли устройство проверки подлинности, например ПИН-код Microsoft Passport, Windows Hello или сканер отпечатков пальцев.

public:
 static IAsyncOperation<UserConsentVerifierAvailability> ^ CheckAvailabilityAsync();
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<UserConsentVerifierAvailability> CheckAvailabilityAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<UserConsentVerifierAvailability> CheckAvailabilityAsync();
function checkAvailabilityAsync()
Public Shared Function CheckAvailabilityAsync () As IAsyncOperation(Of UserConsentVerifierAvailability)

Возвращаемое значение

Значение UserConsentVerifierAvailability, описывающее результат операции проверка доступности.

Атрибуты

Комментарии

В следующем примере показан метод, который проверяет, поддерживается ли устройство проверки подлинности для текущего пользователя, и возвращает сообщение с описанием результата.

public async Task<string> CheckDeviceAvailability()
{
    string returnMessage;

    // Check the availability of device authentication.
    var ucvAvailability = await Windows.Security.Credentials.UI.UserConsentVerifier.CheckAvailabilityAsync();

    switch (ucvAvailability)
    {
        case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.Available:
            returnMessage = "Authentication device is available.";
            break;
        case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.DeviceBusy:
            returnMessage = "Authentication device is busy.";
            break;
        case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.DeviceNotPresent:
            returnMessage = "No authentication device found.";
            break;
        case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.DisabledByPolicy:
            returnMessage = "Authentication device verification is disabled by policy.";
            break;
        case Windows.Security.Credentials.UI.UserConsentVerifierAvailability.NotConfiguredForUser:
            returnMessage = "Please go to Account Settings to set up a PIN or other advanced authentication.";
            break;
        default:
            returnMessage = "Authentication device is currently unavailable.";
            break;
    }

    return returnMessage;
}
winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> CheckDeviceAvailability()
{
    winrt::hstring returnMessage;

    // Check the availability of device authentication.
    auto ucvAvailability = co_await Windows::Security::Credentials::UI::UserConsentVerifier::CheckAvailabilityAsync();

    switch (ucvAvailability)
    {
        case winrt::Windows::Security::Credentials::UI::UserConsentVerifierAvailability::Available:
            returnMessage = L"Authentication device is available.";
            break;
        case winrt::Windows::Security::Credentials::UI::UserConsentVerifierAvailability::DeviceBusy:
            returnMessage = L"Authentication device is busy.";
            break;
        case winrt::Windows::Security::Credentials::UI::UserConsentVerifierAvailability::DeviceNotPresent:
            returnMessage = L"No authentication device found.";
            break;
        case winrt::Windows::Security::Credentials::UI::UserConsentVerifierAvailability::DisabledByPolicy:
            returnMessage = L"Authentication device verification is disabled by policy.";
            break;
        case winrt::Windows::Security::Credentials::UI::UserConsentVerifierAvailability::NotConfiguredForUser:
            returnMessage = L"Please go to Account Settings to set up a PIN or other advanced authentication.";
            break;
        default:
            returnMessage = L"Authentication device is currently unavailable.";
            break;
    }

    co_return returnMessage;
}

Применяется к

См. также раздел