SDKsHarmonyOSEnterprise
Get friend count
Retrieve the total number of friend relationships established by the current account.
Query the aggregate friend relationship count without supplying parameters. This count is useful for contact statistics or determining whether to continue paging:
Code example
import sdk, { GetFriendListCountResp } from '@openimsdk/imsdk';
const response: GetFriendListCountResp = await sdk.getFriendListCount();
showFriendCount(response.count);Return value
Returns a Promise that resolves to a GetFriendListCountResp object:
| Property | Type | Description |
|---|---|---|
count | number | The total count of active friends in the local SDK database. |
State changes after the call
The returned count reflects a point-in-time total and does not emit events. Maintain the count incrementally when friends are added or removed using the events documented in Paginate friend list, and re-query whenever calibration is required.
Was this page helpful?