1# Embedded User Authentication Control
2
3
4## Introduction
5
6Provide face and fingerprint authentication icon displayed on the application interface, with specific functions as follows:
71. Provide embedded face and fingerprint authentication control icon that can be integrated into applications.
82. Support customizing the color and size of icon, but the icon style cannot be changed.
93. After clicking on the control icon, the system pop-up style face and fingerprint authentication control can be pulled up.
10
11
12## Directory Structure
13
14```undefined
15//base/useriam/user_auth_framework/user_auth_icon
16├── library                              # library module directory
17│   ├── src/main/ets/components/mainpage # the entry point for implementing embedded controls
18```
19
20
21### Available APIs
22
23**Table 1** APIs for embedded user authentication
24
25**table1** Icon click event callback interface
26
27| interface  | description                             |
28| ------ | -------------------------------- |
29| onIconClick?: () => void; | Notify the application that a click event has been triggered. |
30
31**table2** Identity authentication result notification callback interface
32
33| interface  | description                             |
34| ------ | -------------------------------- |
35| onAuthResult: (result: userAuth.UserAuthResult) => void; | Notify the application of user authentication result information. |
36
37
38
39## Demo
40
41```undefined
42import userAuth from '@ohos.userIAM.userAuth';
43import UserAuthIcon from '@ohos.userIAM.userAuthIcon';
44
45@Entry
46@Component
47struct Index {
48  authParam: userAuth.AuthParam = {
49    challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
50    authType: [userAuth.UserAuthType.FACE, userAuth.UserAuthType.PIN],
51    authTrustLevel: userAuth.AuthTrustLevel.ATL3,
52  };
53  widgetParam: userAuth.WidgetParam = {
54    title: '请进行身份认证',
55  };
56
57  build() {
58    Row() {
59      Column() {
60        UserAuthIcon({
61          authParam: this.authParam,
62          widgetParam: this.widgetParam,
63          iconHeight: 200,
64          iconColor: Color.Blue,
65          onIconClick: () => {
66            console.info("The user clicked the icon.");
67          },
68          onAuthResult: (result: userAuth.UserAuthResult) => {
69            console.info('Get user auth result, result = ' + JSON.stringify(result));
70          },
71        })
72      }
73    }
74  }
75}
76```
77