이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

Custom Definition Badge

Android

Supported Vendors

Huawei.

Configuration Method

To configure the Huawei badge parameters in the console, set them to the application's startup class, for example, "com.tencent.qcloud.tim.demo.SplashActivity". The component will automatically parse and update the badge; otherwise, it will not update the badge.




iOS

By default, when the App goes into the background, the IMSDK will set the total number of unread IM messages as the badge. If the App is integrated with offline push, when a new offline push notification is received, the App badge will increment by 1 based on the baseline badge (default is the total number of unread IM messages, or the custom-defined badge if one has been set).

Configuration Method

If you want to customize the badge, follow these steps:
1. The App calls the - (void)setAPNSListener:(id<V2TIMAPNSListener>)apnsListener interface to set the listener.
2. The App implements the - (uint32_t)onSetAPPUnreadCount interface and returns the custom-defined badge number.
// 1. Set the listener
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Listen for push notifications
[V2TIMManager.sharedInstance setAPNSListener:self];
// Listen for unread conversation counts
[[V2TIMManager sharedInstance] setConversationListener:self];
return YES;
}

// 2. Save the unread count after it changes
- (void)onTotalUnreadMessageCountChanged:(UInt64)totalUnreadCount {
self.unreadNumber = totalUnreadCount;
}

// 3. Report custom-defined unread count after the app is pushed to the background
/** After the application enters the background, customize the app's unread count. If not handled, the default app unread count is the sum of all conversation unread counts
* <pre>
*
* - (uint32_t)onSetAPPUnreadCount {
* return 100; // Custom-defined unread count
* }
*
* </pre>
*/
- (uint32_t)onSetAPPUnreadCount {
// 1. Get the custom-defined badge
uint32_t customBadgeNumber = ...
// 2. Add the IM message unread count
customBadgeNumber += self.unreadNumber;
// 3. Report to the IM server via IMSDK
return customBadgeNumber;
}

Flutter

For configuration, please refer to the iOS and Android sections below. The methods called are also available in the Flutter version of the IM SDK, with the same names.