Set app badge
Synchronize the unread message count with the SDK’s push notification badge counter.
Invoke setAppBadge() to synchronize the current aggregate unread message count with the OpenIM SDK's internal push badge counter.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
count | number | Yes | Non-negative integer representing the aggregate unread message count. |
Code example
import { setAppBadge } from '@/uni_modules/unix-openim-sdk'
await setAppBadge(totalUnreadCount)Supply a non-negative integer for totalUnreadCount. Typically invoke this method whenever the total unread count changes, after login synchronization concludes, or when all messages are marked as read. Do not pass the unread count of an individual conversation as the application badge.
Return value
The Promise resolves with void upon successful acceptance by the SDK.
State changes after the call
Promise resolution indicates that the SDK accepted the badge value for push notifications; it does not alter conversation unread counts stored locally. To reflect the badge number on the mobile OS app launcher icon, update the platform badge using the appropriate OS notification APIs. For calculating and tracking the global unread count, see Get total unread count.
Was this page helpful?