Release Notes
Announcements

// 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;}
import ImSDK_Plusclass AppDelegate: UIResponder, UIApplicationDelegate, V2TIMAPNSListener, V2TIMConversationListener {var unreadNumber: UInt64 = 0// 1. Set the listenerfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {// Listen for push notificationsV2TIMManager.sharedInstance()?.setAPNSListener(self)// Listen for unread conversation countsV2TIMManager.sharedInstance()?.setConversationListener(self)return true}// 2. Save the unread count after it changesfunc onTotalUnreadMessageCountChanged(_ totalUnreadCount: UInt64) {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/// - Returns: Custom-defined unread countfunc onSetAPPUnreadCount() -> UInt32 {// 1. Get the custom-defined badgevar customBadgeNumber: UInt32 = 0// 2. Add the IM message unread countcustomBadgeNumber += UInt32(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);
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback