Last updated: 2025-02-28 17:55:35
Custom Definition Badge
Last updated: 2025-02-28 17:55:35
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.
By default, when the App goes into the background, the ChatSDK will set the total number of unread Chat 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 Chat messages, or the custom-defined badge if one has been set).
Configuration Method
If you want to customize the badge, follow these steps:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[V2TIMManager.sharedInstance setAPNSListener:self];
[[V2TIMManager sharedInstance] setConversationListener:self];
return YES;
}
- (void)onTotalUnreadMessageCountChanged:(UInt64)totalUnreadCount {
self.unreadNumber = totalUnreadCount;
}
- (uint32_t)onSetAPPUnreadCount {
uint32_t customBadgeNumber = ...
customBadgeNumber += self.unreadNumber;
return customBadgeNumber;
}
Please refer to Android and iOS for configuration. The methods called have the same names in the Flutter version of the IM SDK.
Supported Vendors
Huawei.
Configuration Method
Step 1. Configure the Huawei badge parameters in the console to the application's startup class.
Note:
The startup class for the uniapp application is io.dcloud.PandoraEntry
.
Step 2. Listen to changes in the total unread count of the Chat SDK to set the badge quantity.
2. Set the badge number through plus.runtime.setBadgeNumber
.
let onTotalUnreadMessageCountUpdated = function(event) {
const unreadCount = event.data;
plus.runtime.setBadgeNumber(unreadCount);
};
chat.on(TencentCloudChat.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED, onTotalUnreadMessageCountUpdated);