查询指定认证类型的认证冻结状态
从API version 22开始,开发者可以参考下述开发指导,查询指定认证类型的认证冻结状态,以及剩余可认证次数或还需等待的认证冻结时间。
接口说明
具体参数、返回值、错误码等描述,请参考对应的userAuth.getAuthLockState。
| 接口名称 | 功能描述 |
|---|---|
| getAuthLockState(authType: UserAuthType): Promise<AuthLockState> | 根据指定的认证类型,查询认证冻结状态,用于判断是否可以发起认证。 |
开发步骤
-
申请权限:ohos.permission.ACCESS_BIOMETRIC。
-
指定认证类型(UserAuthType),并调用getAuthLockState接口查询指定认证类型的认证冻结状态。
以查询PIN认证类型的认证冻结状态为例:
async obtainingAuthLockState() : Promise<string> {
try {
Logger.info(`get auth lock state start`);
const authLockState : userAuth.AuthLockState = await userAuth.getAuthLockState(userAuth.UserAuthType.PIN);
if (authLockState.lockoutDuration === userAuth.PERMANENT_LOCKOUT_DURATION) {
Logger.info('the authentication of given authType is permanent locked.');
}
const authLockStateContent : string = JSON.stringify(authLockState);
Logger.info('get auth lock state successfully.');
return authLockStateContent;
} catch (error) {
const errorMessage : string = `get auth lock state failed, err code is : ${error?.code}, err message is : ${error?.message}`;
Logger.error(errorMessage);
return errorMessage;
}
}
示例代码
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 cancel-authentication
openharmony 鸿蒙 obtain-enrolled-state-capabilities
openharmony 鸿蒙 apply-custom-authentication
openharmony 鸿蒙 perceive-adjust-authentication-process
openharmony 鸿蒙 start-authentication
openharmony 鸿蒙 user-authentication-overview