The distributedAccount module provides basic functions for managing distributed accounts, including querying and updating account login status.
The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login status.
> **NOTE**<br>
> **NOTE**<br>
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -25,7 +24,7 @@ Obtains a **DistributedAccountAbility** instance.
...
@@ -25,7 +24,7 @@ Obtains a **DistributedAccountAbility** instance.
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.|
| [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides APIs for querying and updating the login state of a distributed account.|
**Example**
**Example**
```js
```js
...
@@ -34,13 +33,88 @@ Obtains a **DistributedAccountAbility** instance.
...
@@ -34,13 +33,88 @@ Obtains a **DistributedAccountAbility** instance.
## DistributedAccountAbility
## DistributedAccountAbility
Provides methods for querying and updating the login state of a distributed account. You must obtain a **DistributedAccountAbility** instance first.
Provides APIs for querying and updating the login state of a distributed account. You must obtain a **DistributedAccountAbility** instance first.
**Required permissions**: ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS, ohos.permission.GET_DISTRIBUTED_ACCOUNTS, or ohos.permission.DISTRIBUTED_DATASYNC
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.|
Obtains distributed account information. This API uses an asynchronous callback to return the result.
Obtains distributed account information. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getOsAccountDistributedInfo](#getosaccountdistributedinfo9).
@@ -50,24 +124,28 @@ Obtains distributed account information. This API uses an asynchronous callback
...
@@ -50,24 +124,28 @@ Obtains distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.|
| callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.|
Obtains distributed account information. This API uses a promise to return the result.
Obtains distributed account information. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getOsAccountDistributedInfo](#getosaccountdistributedinfo9-1).
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.|
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
Updates distributed account information. This API uses an asynchronous callback to return the result.
Updates distributed account information. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setOsAccountDistributedInfo](#setosaccountdistributedinfo9).
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.|
| callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.|
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
Updates distributed account information. This API uses a promise to return the result.
Updates the distributed account information. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setOsAccountDistributedInfo](#setosaccountdistributedinfo9-1).
@@ -157,7 +320,9 @@ Defines distributed OS account information.
...
@@ -157,7 +320,9 @@ Defines distributed OS account information.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of a distributed account. It must be a non-null string.|
| name | string | Yes| Name of the distributed account. It must be a non-null string.|
| id | string | Yes| UID of a distributed account. It must be a non-null string.|
| id | string | Yes| UID of the distributed account. It must be a non-null string.|
| event | string | Yes| Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>- Ohos.account.event.LOGIN<br>- Ohos.account.event.LOGOUT<br>- Ohos.account.event.TOKEN_INVALID<br>- Ohos.account.event.LOGOFF |
| event | string | Yes| Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>- Ohos.account.event.LOGIN<br>- Ohos.account.event.LOGOUT<br>- Ohos.account.event.TOKEN_INVALID<br>- Ohos.account.event.LOGOFF |
| scalableData | object | No| Extended information about a distributed account. Customized information is passed in key-value pairs.<br>Note: This parameter is reserved and not used in query and update methods.|
| nickname<sup>9+</sup> | string | No| Nickname of the distributed account. It must be a non-null string.|
| avatar<sup>9+</sup> | string | No| Avatar of the distributed account. It must be a non-null string.|
| scalableData | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in query and update methods.|