Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Set application badge count

Synchronize current unread counts with the OpenIM push notification badge status.

Copy

Reports the total displayed unread message count to the OpenIM SDK for server-side push badge management. This API does not directly modify HarmonyOS home screen badge indicators; host applications must integrate system badge capabilities in according to platform specifications.

Code example

import sdk, { SetAppBadgeReq } from '@openimsdk/imsdk';

const request: SetAppBadgeReq = {
  appUnreadCount: totalUnreadCount,
};
await sdk.setAppBadge(request);

Parameters

ParameterTypeRequiredDescription
appUnreadCountnumberYesNon-negative integer representing the aggregate unread message count across the entire application.

Return value

Returns a Promise that resolves to void when the badge value is acknowledged by the SDK.

State changes after the call

Pass a non-negative integer for appUnreadCount. Typically update this counter after total unread changes, initial sync completion, or clearing unread messages; do not report an individual conversation's unread count as the application aggregate. Promise resolution indicates acceptance by the SDK, without implying native HarmonyOS home screen badge presentation or altering conversation-level unread counts. To query unread totals or handle unread events, see Get total unread message count.