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 userAuth.getEnrolledState.
| API | Description |
|---|---|
| getEnrolledState(authType : UserAuthType): EnrolledState | Obtains the status of the enrolled credentials based on the specified authentication type. |
How to Develop
-
Check that the application has the ohos.permission.ACCESS_BIOMETRIC permission. For details about how to request permissions, see Requesting Permissions.
-
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.
obtainingEnrolledCredentialInformation() {
try {
let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FACE);
Logger.info('get current enrolled state successfully');
return enrolledState.credentialDigest;
} catch (error) {
const err: BusinessError = error as BusinessError;
Logger.error(`get current enrolled state failed, Code is ${err?.code}, message is ${err?.message}`);
return false;
}
}