同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
说明: 从API Version 7 开始支持。
import account_distributedAccount from '@ohos.account.distributedAccount';
getDistributedAccountAbility(): DistributedAccountAbility
获取分布式帐号单实例对象。
返回值:
示例:
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
提供查询和更新分布式帐号登录状态方法(需要先获取分布式帐号的单实例对象)。
queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): void
获取分布式帐号信息,使用callback回调异步返回结果。
需要权限:ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅供系统应用使用。
参数:
AsyncCallback<DistributedInfo> |
示例:
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err));
console.log('Query account info name: ' + data.name);
console.log('Query account info id: ' + data.id);
});
queryOsAccountDistributedInfo(): Promise<DistributedInfo>
获取分布式帐号信息,使用Promise方式异步返回结果。
需要权限:ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅供系统应用使用。
返回值:
Promise<DistributedInfo> |
示例:
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name);
console.log('Query account info id: ' + data.id);
}).catch((err) => {
console.log("queryOsAccountDistributedInfoerr: " + JSON.stringify(err));
});
updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback<void>): void
更新分布式帐号信息,使用callback回调异步返回结果。
需要权限:ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅供系统应用使用。
参数:
示例:
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err));
});
updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void>
更新分布式帐号信息,使用Promise方式异步返回结果。
需要权限:ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅供系统应用使用。
参数:
返回值:
示例:
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
console.log('updateOsAccountDistributedInfo Success');
}).catch((err) => {
console.log("updateOsAccountDistributedInfo err: " + JSON.stringify(err));
});
提供操作系统帐户的分布式信息。
分布式帐号登录状态,包括登录、登出、Token失效和注销,分别对应以下字符串:
|
|||
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。