
// 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 badgeuint32_t customBadgeNumber = ...// 2. Add the IM message unread countcustomBadgeNumber += self.unreadNumber;// 3. Report to the IM server via IMSDKreturn customBadgeNumber;}
io.dcloud.PandoraEntry.
plus.runtime.setBadgeNumber.let onTotalUnreadMessageCountUpdated = function(event) {const unreadCount = event.data; // Total unread count of the current sessionplus.runtime.setBadgeNumber(unreadCount); // Set the badge number};chat.on(TencentCloudChat.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED, onTotalUnreadMessageCountUpdated);
フィードバック