Obtaining Supported Authentication Capabilities
Different devices support different authentication capabilities (facial authentication, fingerprint authentication, and password authentication). Before you start coding, obtain the authentication capabilities supported by the target device.
Available APIs
For details about the parameters, return values, and error codes, see userAuth.getAvailableStatus.
| API | Description |
|---|---|
| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | Checks whether the specified authentication type and authentication trust level are supported by the device. |
How to Develop
-
Request the ohos.permission.ACCESS_BIOMETRIC permission.
-
Call getAvailableStatus to check whether the device supports the specified authentication type (UserAuthType) and authentication trust level (AuthTrustLevel).
For details about the authentication trust levels, see Principles for Classifying Biometric Authentication Trust Levels.
Example: Check whether the device supports facial authentication of ATL3 or higher.
obtainingSupported() {
try {
// Check whether the specified authentication capabilities are supported.
userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL3);
Logger.info('current auth trust level is supported');
return true;
} catch (error) {
const err: BusinessError = error as BusinessError;
Logger.error(`current auth trust level is not supported, code is ${err?.code}, message is ${err?.message}`);
return false;
}
}