Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8c8e9fe4
D
Docs
项目概览
OpenHarmony
/
Docs
10 个月 前同步成功
通知
158
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8c8e9fe4
编写于
7月 21, 2023
作者:
L
liuziweicom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix for code sample
Signed-off-by:
N
liuziweicom
<
liuziwei12@huawei.com
>
上级
b7079ae9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
58 deletion
+47
-58
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
...pplication-dev/reference/apis/js-apis-useriam-userauth.md
+47
-58
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
浏览文件 @
8c8e9fe4
...
...
@@ -43,11 +43,11 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth';
**系统能力**
:SystemCapability.UserIAM.UserAuth.Core
| 名称 | 类型 | 必填 | 说明 |
| -------------------- | ----------------------------------- | ---- | ------------------------ |
| title | string | 是 | 用户认证界面的标题
。
|
| navigationButtonText | string | 否 | 导航按键的说明文本
。
|
| windowModeType |
[
WindowModeType
](
#windowmodetype10
)
| 否 | 用户认证界面的显示类型。 |
| 名称 | 类型 | 必填 | 说明
|
| -------------------- | ----------------------------------- | ---- | ------------------------
---------------
|
| title | string | 是 | 用户认证界面的标题
,最大长度为500字符。
|
| navigationButtonText | string | 否 | 导航按键的说明文本
,最大长度为60字符。
|
| windowModeType |
[
WindowModeType
](
#windowmodetype10
)
| 否 | 用户认证界面的显示类型。
|
## UserAuthResult<sup>10+</sup>
...
...
@@ -91,17 +91,17 @@ const authParam = {
authTrustLevel
:
10000
,
};
const
widgetParam
=
{
title
:
string
=
'
请输入密码
'
,
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
await
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
console
.
log
(
'
get userAuth instance success
'
);
userAuthInstance
.
on
(
'
result
'
,
{
callback
:
function
(
result
)
{
LogUtils
.
info
(
TAG
,
'
userAuthInstance callback result =
'
+
JSON
.
stringify
(
result
));
}
onResult
(
result
)
{
console
.
log
(
'
userAuthInstance callback result =
'
+
JSON
.
stringify
(
result
));
}
});
console
.
log
(
'
auth on success
'
);
}
catch
(
error
)
{
...
...
@@ -149,17 +149,17 @@ const authParam = {
authTrustLevel
:
10000
,
};
const
widgetParam
=
{
title
:
string
=
'
请输入密码
'
,
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
await
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
console
.
log
(
'
get userAuth instance success
'
);
userAuthInstance
.
on
(
'
result
'
,
{
callback
:
function
(
result
)
{
LogUtils
.
info
(
TAG
,
'
userAuthInstance callback result =
'
+
JSON
.
stringify
(
result
));
}
onResult
(
result
)
{
console
.
log
(
'
userAuthInstance callback result =
'
+
JSON
.
stringify
(
result
));
}
});
console
.
log
(
'
auth on success
'
);
}
catch
(
error
)
{
...
...
@@ -204,15 +204,15 @@ const authParam = {
authTrustLevel
:
10000
,
};
const
widgetParam
=
{
title
:
string
=
'
请输入密码
'
,
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
await
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
console
.
log
(
'
get userAuth instance success
'
);
userAuthInstance
.
off
(
'
result
'
,
{
callback
:
function
(
result
)
{
onResult
(
result
)
{
console
.
log
(
'
auth off result:
'
+
JSON
.
stringify
(
result
));
}
});
...
...
@@ -262,12 +262,12 @@ const authParam = {
authTrustLevel
:
10000
,
};
const
widgetParam
=
{
title
:
string
=
'
请输入密码
'
,
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
await
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
console
.
log
(
'
get userAuth instance success
'
);
userAuthInstance
.
start
();
console
.
log
(
'
auth start success
'
);
...
...
@@ -301,26 +301,21 @@ cancel(): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
authType
:
Array
<
userAuth
.
UserAuthType
>
=
[];
authType
.
push
(
userAuth
.
UserAuthType
.
PIN
);
authType
.
push
(
userAuth
.
UserAuthType
.
FACE
);
authType
.
push
(
userAuth
.
UserAuthType
.
FINGERPRINT
);
const
authParam
=
{
authType
:
authType
,
challenge
:
new
Uint8Array
([
4
,
49
,
49
,
49
,
49
,
49
])
,
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
])
,
authType
:
[
userAuth
.
UserAuthType
.
PIN
]
,
authTrustLevel
:
10000
,
};
const
widgetParam
=
{
title
:
string
=
'
'
,
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
await
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
console
.
log
(
'
get userAuth instance success
'
);
userAuthInstance
.
cancel
();
console
.
log
(
'
auth cancel success
'
)
)
;
console
.
log
(
'
auth cancel success
'
);
}
catch
(
error
)
{
console
.
log
(
'
auth catch error:
'
+
JSON
.
stringify
(
error
));
}
...
...
@@ -368,23 +363,18 @@ getUserAuthInstance(authParam: AuthParam, widgetParam: WidgetParam): UserAuthIns
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
authType
:
Array
<
userAuth
.
UserAuthType
>
=
[];
authType
.
push
(
userAuth
.
UserAuthType
.
PIN
);
authType
.
push
(
userAuth
.
UserAuthType
.
FACE
);
authType
.
push
(
userAuth
.
UserAuthType
.
FINGERPRINT
);
const
authParam
=
{
authType
:
authType
,
challenge
:
new
Uint8Array
([
4
,
49
,
49
,
49
,
49
,
49
])
,
authTrustLevel
:
userAuth
.
AuthTrustLevel
.
ATL1
,
challenge
:
new
Uint8Array
([
49
,
49
,
49
,
49
,
49
,
49
])
,
authType
:
[
userAuth
.
UserAuthType
.
PIN
]
,
authTrustLevel
:
10000
,
};
const
widgetParam
=
{
title
:
string
=
'
'
,
title
:
'
请输入密码
'
,
navigationButtonText
:
'
返回
'
,
windowMode
:
userAuth
.
WindowModeType
.
DIALOG_BOX
,
};
try
{
let
userAuthInstance
=
await
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
let
userAuthInstance
=
userAuth
.
getUserAuthInstance
(
authParam
,
widgetParam
);
console
.
log
(
'
get userAuth instance success
'
);
}
catch
(
error
)
{
console
.
log
(
'
auth catch error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -445,10 +435,11 @@ try {
version
:
'
1
'
,
payload
:
{
type
:
[
'
pin
'
]
};
},
};
const
jsonEventData
=
JSON
.
stringify
(
eventData
);
let
noticeType
=
userAuth
.
NoticeType
.
WIDGET_NOTICE
;
sendNotice
(
noticeType
,
{
jsonEventData
}
);
userAuth
.
sendNotice
(
noticeType
,
jsonEventData
);
console
.
log
(
'
sendNotice success
'
);
}
catch
(
error
)
{
console
.
log
(
'
sendNotice catch error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -490,12 +481,12 @@ on(type: 'command', callback: IAuthWidgetCallback): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
static
userAuthWidgetMgrVersion
=
1
;
const
userAuthWidgetMgrVersion
=
1
;
try
{
let
userAuthWidgetMgr
=
await
userAuth
.
getUserAuthWidgetMgr
(
userAuthWidgetMgrVersion
);
let
userAuthWidgetMgr
=
userAuth
.
getUserAuthWidgetMgr
(
userAuthWidgetMgrVersion
);
console
.
log
(
'
get userAuthWidgetMgr instance success
'
);
userAuthWidgetMgr
.
on
(
'
command
'
,
{
callback
:
sendCommand
(
cmdData
)
{
sendCommand
(
cmdData
)
{
console
.
log
(
'
The cmdData is
'
+
cmdData
);
}
})
...
...
@@ -536,17 +527,15 @@ off(type: 'command', callback?: IAuthWidgetCallback): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
v
ersion
=
1
;
const
userAuthWidgetMgrV
ersion
=
1
;
try
{
let
userAuthWidgetMgr
=
await
userAuth
.
getUserAuthWidgetMgr
(
v
ersion
);
console
.
info
(
'
get userAuthWidgetMgr instance success
'
);
userAuthWidgetMgr
.
o
n
(
'
command
'
,
{
callback
:
sendCommand
(
cmdData
)
{
let
userAuthWidgetMgr
=
userAuth
.
getUserAuthWidgetMgr
(
userAuthWidgetMgrV
ersion
);
console
.
log
(
'
get userAuthWidgetMgr instance success
'
);
userAuthWidgetMgr
.
o
ff
(
'
command
'
,
{
sendCommand
(
cmdData
)
{
console
.
log
(
'
The cmdData is
'
+
cmdData
);
}
})
console
.
log
(
'
subscribe authentication event success
'
);
userAuthWidgetMgr
.
off
(
'
command
'
);
console
.
log
(
'
cancel subscribe authentication event success
'
);
}
catch
(
error
)
{
console
.
log
(
'
userAuth widgetMgr catch error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -596,9 +585,9 @@ getUserAuthWidgetMgr(version: number): UserAuthWidgetMgr
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
v
ersion
=
1
;
let
userAuthWidgetMgrV
ersion
=
1
;
try
{
let
userAuthWidgetMgr
=
await
userAuth
.
getUserAuthWidgetMgr
(
v
ersion
);
let
userAuthWidgetMgr
=
userAuth
.
getUserAuthWidgetMgr
(
userAuthWidgetMgrV
ersion
);
console
.
log
(
'
get userAuthWidgetMgr instance success
'
);
}
catch
(
error
)
{
console
.
log
(
'
userAuth widgetMgr catch error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -630,12 +619,12 @@ sendCommand(cmdData: string): void
```
js
import
userAuth
from
'
@ohos.userIAM.userAuth
'
;
let
v
ersion
=
1
;
const
userAuthWidgetMgrV
ersion
=
1
;
try
{
let
userAuthWidgetMgr
=
await
userAuth
.
getUserAuthWidgetMgr
(
v
ersion
);
let
userAuthWidgetMgr
=
userAuth
.
getUserAuthWidgetMgr
(
userAuthWidgetMgrV
ersion
);
console
.
log
(
'
get userAuthWidgetMgr instance success
'
);
userAuthWidgetMgr
.
on
(
'
command
'
,
{
callback
:
sendCommand
(
cmdData
)
{
sendCommand
(
cmdData
)
{
console
.
log
(
'
The cmdData is
'
+
cmdData
);
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录