Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Coping0606
Docs
提交
72ee79c9
D
Docs
项目概览
Coping0606
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
1
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
未验证
提交
72ee79c9
编写于
8月 23, 2022
作者:
Z
zengyawen
提交者:
Gitee
8月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-appAccount.md.
Signed-off-by:
N
zengyawen
<
zengyawen1@huawei.com
>
上级
55ec912d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
27 deletion
+29
-27
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
+29
-27
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
浏览文件 @
72ee79c9
...
...
@@ -15,7 +15,7 @@ import account_appAccount from '@ohos.account.appAccount';
createAppAccountManager(): AppAccountManager
应用帐号管理:
获取应用帐号模块对象。
获取应用帐号模块对象。
**系统能力:**
SystemCapability.Account.AppAccount
...
...
@@ -151,7 +151,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
}
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
addAccountImplicitly
(
"
LiSi
"
,
"
readAge
"
,
{},
{
appAccountManager
.
addAccountImplicitly
(
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
,
{},
{
onResult
:
onResultCallback
,
onRequestRedirected
:
onRequestRedirectedCallback
});
...
...
@@ -318,7 +318,8 @@ enableAppAccess(name: string, bundleName: string): Promise<void>
**示例:**
```
js
app_account_instance
.
enableAppAccess
(
"
ZhangSan
"
,
"
com.example.ohos.accountjsdemo
"
).
then
(()
=>
{
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
enableAppAccess
(
"
ZhangSan
"
,
"
com.example.ohos.accountjsdemo
"
).
then
(()
=>
{
console
.
log
(
'
enableAppAccess Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
enableAppAccess err:
"
+
JSON
.
stringify
(
err
));
...
...
@@ -331,7 +332,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>):
检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
,仅系统应用可用。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:**
SystemCapability.Account.AppAccount
...
...
@@ -358,7 +359,7 @@ checkAppAccountSyncEnable(name: string): Promise<boolean>
检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
,仅系统应用可用。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:**
SystemCapability.Account.AppAccount
...
...
@@ -507,7 +508,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
,仅系统应用可用。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:**
SystemCapability.Account.AppAccount
...
...
@@ -534,7 +535,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
,仅系统应用可用。
**需要权限:**
ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:**
SystemCapability.Account.AppAccount
...
...
@@ -582,7 +583,8 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb
**示例:**
```
js
app_account_instance
.
setAssociatedData
(
"
ZhangSan
"
,
"
k001
"
,
"
v001
"
,
(
err
)
=>
{
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
setAssociatedData
(
"
ZhangSan
"
,
"
k001
"
,
"
v001
"
,
(
err
)
=>
{
console
.
log
(
"
setAssociatedData err:
"
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1007,7 +1009,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
}
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
authenticate
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
,
{},
{
appAccountManager
.
authenticate
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
,
{},
{
onResult
:
onResultCallback
,
onRequestRedirected
:
onRequestRedirectedCallback
});
...
...
@@ -1034,7 +1036,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
getOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
,
(
err
,
data
)
=>
{
appAccountManager
.
getOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
,
(
err
,
data
)
=>
{
console
.
log
(
'
getOAuthToken err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOAuthToken token:
'
+
data
);
});
...
...
@@ -1066,7 +1068,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string&
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
getOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
).
then
((
data
)
=>
{
appAccountManager
.
getOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
).
then
((
data
)
=>
{
console
.
log
(
'
getOAuthToken token:
'
+
data
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
getOAuthToken err:
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1094,7 +1096,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
setOAuthToken
(
"
LiSi
"
,
"
readAge
"
,
"
xxxx
"
,
(
err
)
=>
{
appAccountManager
.
setOAuthToken
(
"
LiSi
"
,
"
getSocialData
"
,
"
xxxx
"
,
(
err
)
=>
{
console
.
log
(
'
setOAuthToken err:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1125,7 +1127,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void>
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
setOAuthToken
(
"
LiSi
"
,
"
readAge
"
,
"
xxxx
"
).
then
(()
=>
{
appAccountManager
.
setOAuthToken
(
"
LiSi
"
,
"
getSocialData
"
,
"
xxxx
"
).
then
(()
=>
{
console
.
log
(
'
setOAuthToken successfully
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
setOAuthToken err:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1154,7 +1156,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
deleteOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
,
"
xxxxx
"
,
(
err
)
=>
{
appAccountManager
.
deleteOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
,
"
xxxxx
"
,
(
err
)
=>
{
console
.
log
(
'
deleteOAuthToken err:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1186,7 +1188,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
deleteOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
,
"
xxxxx
"
).
then
(()
=>
{
appAccountManager
.
deleteOAuthToken
(
"
LiSi
"
,
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
,
"
xxxxx
"
).
then
(()
=>
{
console
.
log
(
'
deleteOAuthToken successfully
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
deleteOAuthToken err:
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1215,7 +1217,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
setOAuthTokenVisibility
(
"
LiSi
"
,
"
readAge
"
,
"
com.example.ohos.accountjsdemo
"
,
true
,
(
err
)
=>
{
appAccountManager
.
setOAuthTokenVisibility
(
"
LiSi
"
,
"
getSocialData
"
,
"
com.example.ohos.accountjsdemo
"
,
true
,
(
err
)
=>
{
console
.
log
(
'
setOAuthTokenVisibility err:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1247,7 +1249,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
setOAuthTokenVisibility
(
"
LiSi
"
,
"
readAge
"
,
"
com.example.ohos.accountjsdemo
"
,
true
).
then
(()
=>
{
appAccountManager
.
setOAuthTokenVisibility
(
"
LiSi
"
,
"
getSocialData
"
,
"
com.example.ohos.accountjsdemo
"
,
true
).
then
(()
=>
{
console
.
log
(
'
setOAuthTokenVisibility successfully
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
setOAuthTokenVisibility err:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1275,7 +1277,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
checkOAuthTokenVisibility
(
"
LiSi
"
,
"
readAge
"
,
"
com.example.ohos.accountjsdemo
"
,
true
,
(
err
,
data
)
=>
{
appAccountManager
.
checkOAuthTokenVisibility
(
"
LiSi
"
,
"
getSocialData
"
,
"
com.example.ohos.accountjsdemo
"
,
(
err
,
data
)
=>
{
console
.
log
(
'
checkOAuthTokenVisibility err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOAuthTokenVisibility isVisible:
'
+
data
);
});
...
...
@@ -1307,7 +1309,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
checkOAuthTokenVisibility
(
"
LiSi
"
,
"
readAge
"
,
"
com.example.ohos.accountjsdemo
"
,
true
).
then
((
data
)
=>
{
appAccountManager
.
checkOAuthTokenVisibility
(
"
LiSi
"
,
"
getSocialData
"
,
"
com.example.ohos.accountjsdemo
"
).
then
((
data
)
=>
{
console
.
log
(
'
checkOAuthTokenVisibility isVisible:
'
+
data
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
checkOAuthTokenVisibility err:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1392,7 +1394,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
getOAuthList
(
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
,
(
err
,
data
)
=>
{
appAccountManager
.
getOAuthList
(
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
,
(
err
,
data
)
=>
{
console
.
log
(
'
getOAuthList err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOAuthList data:
'
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1423,7 +1425,7 @@ getOAuthList(name: string, authType: string): Promise<Array<string>>
```
js
const
appAccountManager
=
account_appAccount
.
createAppAccountManager
();
appAccountManager
.
getOAuthList
(
"
com.example.ohos.accountjsdemo
"
,
"
readAge
"
).
then
((
data
)
=>
{
appAccountManager
.
getOAuthList
(
"
com.example.ohos.accountjsdemo
"
,
"
getSocialData
"
).
then
((
data
)
=>
{
console
.
log
(
'
getOAuthList data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
log
(
"
getOAuthList err:
"
+
JSON
.
stringify
(
err
));
...
...
@@ -1458,7 +1460,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic
}
var
result
=
{[
account_appAccount
.
Constants
.
KEY_NAME
]:
"
LiSi
"
,
[
account_appAccount
.
Constants
.
KEY_OWNER
]:
"
com.example.ohos.accountjsdemo
"
,
[
account_appAccount
.
Constants
.
KEY_AUTH_TYPE
]:
"
readAge
"
,
[
account_appAccount
.
Constants
.
KEY_AUTH_TYPE
]:
"
getSocialData
"
,
[
account_appAccount
.
Constants
.
KEY_TOKEN
]:
"
xxxxxx
"
};
callback
.
OnResult
(
account_appAccount
.
ResultCode
.
SUCCESS
,
result
);
});
...
...
@@ -1494,7 +1496,7 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>
appAccountManager
.
getAuthenticatorCallback
(
sessionId
).
then
((
callback
)
=>
{
var
result
=
{[
account_appAccount
.
Constants
.
KEY_NAME
]:
"
LiSi
"
,
[
account_appAccount
.
Constants
.
KEY_OWNER
]:
"
com.example.ohos.accountjsdemo
"
,
[
account_appAccount
.
Constants
.
KEY_AUTH_TYPE
]:
"
readAge
"
,
[
account_appAccount
.
Constants
.
KEY_AUTH_TYPE
]:
"
getSocialData
"
,
[
account_appAccount
.
Constants
.
KEY_TOKEN
]:
"
xxxxxx
"
};
callback
.
OnResult
(
account_appAccount
.
ResultCode
.
SUCCESS
,
result
);
}).
catch
((
err
)
=>
{
...
...
@@ -1592,8 +1594,8 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ---------- |
| owner | string | 是 | 认证器的所有者包名。 |
| iconId |
string
| 是 | 认证器的图标标识。 |
| labelId |
string
| 是 | 认证器的标签标识。 |
| iconId |
number
| 是 | 认证器的图标标识。 |
| labelId |
number
| 是 | 认证器的标签标识。 |
## Constants<sup>8+</sup>
...
...
@@ -1669,7 +1671,7 @@ onResult: (code: number, result: {[key: string]: any}) => void
appAccountManager
.
getAuthenticatorCallback
(
sessionId
).
then
((
callback
)
=>
{
var
result
=
{[
account_appAccount
.
Constants
.
KEY_NAME
]:
"
LiSi
"
,
[
account_appAccount
.
Constants
.
KEY_OWNER
]:
"
com.example.ohos.accountjsdemo
"
,
[
account_appAccount
.
Constants
.
KEY_AUTH_TYPE
]:
"
readAge
"
,
[
account_appAccount
.
Constants
.
KEY_AUTH_TYPE
]:
"
getSocialData
"
,
[
account_appAccount
.
Constants
.
KEY_TOKEN
]:
"
xxxxxx
"
};
callback
.
OnResult
(
account_appAccount
.
ResultCode
.
SUCCESS
,
result
);
}).
catch
((
err
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录