Technology Sharing

Hongmeng development management: [@ohos.account.distributedAccount (distributed account management)]

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Distributed Account Management

This module provides some basic functions for managing distributed accounts, mainly including querying and updating account login status.

illustrate: The first batch of interfaces in this module are supported starting from API version 7. For new interfaces in subsequent versions, the starting version of the interface is marked with a superscript.Please familiarize yourself with the Hongmeng development guide before developmentgitee.com/li-shizhen-skin/harmony-os/blob/master/README.mdClick or copy to go.

Importing modules

import account_distributedAccount from '@ohos.account.distributedAccount';

account_distributedAccount.getDistributedAccountAbility

getDistributedAccountAbility(): DistributedAccountAbility

Get the distributed account instance object.

System capabilities: SystemCapability.Account.OsAccount

  • return value:

    | Type | Description |
    | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
    | [DistributedAccountAbility]| Returns an instance that provides methods for querying and updating distributed account login status. |

  • Example:

    const accountAbility = account_distributedAccount.getDistributedAccountAbility();
    

DistributedAccountAbility

Provides methods for querying and updating the distributed account login status (need to obtain the single instance object of the distributed account first).

queryOsAccountDistributedInfo

queryOsAccountDistributedInfo(callback: AsyncCallback): void

Get distributed account information and use callback to return the result asynchronously.

System capabilities: SystemCapability.Account.OsAccount

Required permissions: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC, this permission is only for system applications.

  • parameter:

    | Parameter name | Type | Required | Description |
    | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | – | ------------- |
    | callback | AsyncCallback