harmony 鸿蒙Obtaining Supported Authentication Capabilities
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 value, and error codes, see 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 ATL1 or higher.
import { BusinessError } from '@kit.BasicServicesKit';
import { userAuth } from '@kit.UserAuthenticationKit';
// Check whether the specified authentication capabilities are supported.
try {
userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL1);
console.info('current auth trust level is supported');
} catch (error) {
const err: BusinessError = error as BusinessError;
console.error(`current auth trust level is not supported. Code is ${err?.code}, message is ${err?.message}`);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙User Authentication Kit (User Authentication Service)
harmony 鸿蒙Applying Custom Authentication
harmony 鸿蒙Canceling User Authentication
harmony 鸿蒙Obtaining Enrolled Credential Status
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦