harmony 鸿蒙Obtaining Enrolled Credential Status

  • 2025-06-12
  • 浏览 (3)

Obtaining Enrolled Credential Status

Use getEnrolledState() to obtain the change in the credentials (face, fingerprint, and password) enrolled by a user.

Available APIs

For details about the parameters, return values, and error codes, see getEnrolledState.

API Description
getEnrolledState(authType : UserAuthType): EnrolledState Obtains the status of the enrolled credentials based on the specified authentication type.

How to Develop

  1. Check that the application has the ohos.permission.ACCESS_BIOMETRIC permission. For details about how to request permissions, see Requesting Permissions.

  2. Specify the authentication type (UserAuthType) and call getEnrolledState to obtain the status of the credentials enrolled by the user.

Example: Obtain information about the credentials enrolled for facial authentication.

import { BusinessError } from  '@kit.BasicServicesKit';
import { userAuth } from '@kit.UserAuthenticationKit';

try {
  let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FACE);
  console.info(`get current enrolled state success, enrolledState: ${JSON.stringify(enrolledState)}`);
} catch (error) {
  const err: BusinessError = error as BusinessError;
  console.error(`get current enrolled state failed, 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 Supported Authentication Capabilities

harmony 鸿蒙Before You Start

harmony 鸿蒙Initiating User Authentication

harmony 鸿蒙Using userAuthIcon

harmony 鸿蒙Introduction to User Authentication Kit

0  赞