SDKsiOS
Set the app badge count
Synchronize the app's current unread count with the OpenIMClientSDK push badge state.
Invoke setAppBadge:onSuccess:onFailure: to report the application's overall unread message count to the SDK, synchronizing badge numbers with the server and push notification services:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
count | NSInteger | Yes | The aggregate total unread message count across the entire application (non-negative integer). Pass the global unread count rather than a single conversation's count. |
Code example
[[OIMManager manager] setAppBadge:totalUnreadCount
onSuccess:^(NSString * _Nullable data) {
NSLog(@"setAppBadge success");
}
onFailure:^(NSInteger code, NSString * _Nullable msg) {
NSLog(@"setAppBadge failed: %ld %@", (long)code, msg);
}];Return value
The onSuccess callback returns confirmation when the SDK successfully records the badge count.
State changes after the call
- Push service synchronization: This call updates badge metadata for backend push delivery; it does not alter conversation-level unread records. To update the app icon badge on the iOS home screen, pair this call with Apple's user notification framework.
- Re-query calibration: For unread counter calculation and listener maintenance, refer to Retrieve and maintain the total unread count.
Was this page helpful?