• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Obtaining Enrolled Credential Status
2
3<!--Kit: User Authentication Kit-->
4<!--Subsystem: UserIAM-->
5<!--Owner: @WALL_EYE-->
6<!--SE: @lichangting518-->
7<!--TSE: @jane_lz-->
8
9Use **getEnrolledState()** to obtain the change in the credentials (face, fingerprint, and password) enrolled by a user.
10
11## Available APIs
12
13For details about the parameters, return values, and error codes, see [getEnrolledState](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#userauthgetenrolledstate12).
14
15| API| Description|
16| -------- | -------- |
17| getEnrolledState(authType : UserAuthType): EnrolledState | Obtains the status of the enrolled credentials based on the specified authentication type.|
18
19## How to Develop
20
211. Check that the application has the ohos.permission.ACCESS_BIOMETRIC permission. For details about how to request permissions, see [Requesting Permissions](prerequisites.md#requesting-permissions).
22
232. Specify the authentication type ([UserAuthType](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#userauthtype8)) and call [getEnrolledState](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#userauthgetenrolledstate12) to obtain the status of the credentials enrolled by the user.
24
25Example: Obtain information about the credentials enrolled for facial authentication.
26
27```ts
28import { BusinessError } from  '@kit.BasicServicesKit';
29import { userAuth } from '@kit.UserAuthenticationKit';
30
31try {
32  let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FACE);
33  console.info(`get current enrolled state success, enrolledState: ${JSON.stringify(enrolledState)}`);
34} catch (error) {
35  const err: BusinessError = error as BusinessError;
36  console.error(`get current enrolled state failed, Code is ${err?.code}, message is ${err?.message}`);
37}
38```
39