BiometricAuthenticator QML Type

Provides interface tools for biometric authentication. More...

Import Statement: import ArcGIS.AppFramework.Authentication 1.0

Properties

Signals

Methods

Detailed Description

Biometric authentication is a way of verifying a user's identity based on a physical attribute. The BiometricAuthenticator component provides an interface for implementing biometric authentication in apps for use in devices that support biometric authentication, such as fingerprint scanning and face ID. To use this capability, you have to set the message property and call the authenticate method.

This component is a singleton, and as such does not need to be instantiated.

This code sample demonstrates a basic usage of BiometricAuthentication. When this sample is run, it prompts the user to authenticate if biometric authentication is supported by the device. Depending on the results of the authentication, it either displays "Authentication Failed" or "Authentication Successful".

Rectangle {
    id: app

    width: 400
    height: 640

    Text {
        id: status

        font.pixelSize: 18
        anchors.centerIn: parent
    }

    Component.onCompleted: {
        if (BiometricAuthenticator.supported && BiometricAuthenticator.activated) {
            BiometricAuthenticator.message = "Please authenticate to proceed.";
            BiometricAuthenticator.authenticate();
        } else {
            status.text = "Not supported";
        }
    }

    Connections {
        target: BiometricAuthenticator

        onRejected: {
            status.text = "Authentication failed";
        }

        onAccepted: {
            status.text = "Authentication Successful";
        }
    }
}

Enumerations

Reason enumeration

This enum describes the potential reasons that a biometric authentication attempt can fail.

NameValue
BiometricAuthenticator.Success0
BiometricAuthenticator.CancelledByUser1
BiometricAuthenticator.InValidCredentials2
BiometricAuthenticator.BiometricNotConfigured3
BiometricAuthenticator.UserFallback4
BiometricAuthenticator.PermissionDenied5
BiometricAuthenticator.BiometricNotSupported6
BiometricAuthenticator.BadCapture7
BiometricAuthenticator.PlatformNotSupported8

Property Documentation

[read-only] activated : bool

Returns true if biometric authentication is activated. Otherwise, returns false.

Rectangle {

    property color successColor: "green"
    property color errorColor: "red"

    anchors.fill: parent
    color: BiometricAuthenticator.activated ? successColor : errorColor
}

[read-only] errorMessage : string

The message displayed when the authentication attempt has failed. Make sure to check for this property only when a device is supported.

Label {
    text: BiometricAuthenticator.errorMessage
    font.pixelSize: 16
    visible: BiometricAuthenticator.errorMessage !== "No Error"
}

message : string

A custom message displayed in the authentication dialog box. This property has to be set along with the authenticate method in order to call a platform-native biometric authentication dialog box. This property also has to be set before calling the authenticate method.

Component.onCompleted: {
    BiometricAuthenticator.message = "Please authenticate your identity to log into your account."
    BiometricAuthenticator.authenticate()
}

[read-only] supported : bool

Returns true if biometric authentication is supported on this device. Otherwise, returns false.

Text {
    id: supportCheck
    text: BiometricAuthenticator.supported ? "Authentication supported" : "Authentication not supported"
}

Signal Documentation

accepted()

Signal emitted when the biometric authentication has been accepted.

Text {
    id:statusMessage

    Connections {
        target:BiometricAuthenticator

        onAccepted :{
            statusMessage.text = qsTr("Success")
        }
    }
}

Note: The corresponding handler is onAccepted.


rejected(Reason reason)

Signal emitted when the biometric authentication attempt has been rejected.

Text {
    id:statusMessage

    Connections {
        target:BiometricAuthenticator

        onRejected: {
            statusMessage.text = qsTr("Fail")
        }
    }
}

Note: The corresponding handler is onRejected.


Method Documentation

authenticate()

Displays a platform-native authentication dialog box.

Button {
    id: touchIDButton
    text: "Touch ID"
    onClicked: {
        BiometricAuthenticator.authenticate()
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.