产品动态
公告

// 1. 设置监听- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// 监听推送[V2TIMManager.sharedInstance setAPNSListener:self];// 监听会话的未读数[[V2TIMManager sharedInstance] setConversationListener:self];return YES;}// 2. 未读数发生变化后保存未读数- (void)onTotalUnreadMessageCountChanged:(UInt64)totalUnreadCount {self.unreadNumber = totalUnreadCount;}// 3. App 推到后台后上报自定义未读数/** 程序进后台后,自定义 App 的未读数,如果不处理,App 未读数默认为所有会话未读数之和* <pre>** - (uint32_t)onSetAPPUnreadCount {* return 100; // 自定义未读数* }** </pre>*/- (uint32_t)onSetAPPUnreadCount {// 1. 获取自定义的角标uint32_t customBadgeNumber = ...// 2. 加上 IM 的消息未读数customBadgeNumber += self.unreadNumber;// 3. 通过 IMSDK 上报给 IM 服务器return customBadgeNumber;}
import ImSDK_Plusclass AppDelegate: UIResponder, UIApplicationDelegate, V2TIMAPNSListener, V2TIMConversationListener {// 存储未读数var unreadNumber: UInt64 = 0// 1. 设置监听func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {// 监听推送V2TIMManager.sharedInstance()?.setAPNSListener(self)// 监听会话的未读数V2TIMManager.sharedInstance()?.setConversationListener(self)return true}// 2. 未读数发生变化后保存未读数func onTotalUnreadMessageCountChanged(_ totalUnreadCount: UInt64) {self.unreadNumber = totalUnreadCount}// 3. App 推到后台后上报自定义未读数/// 程序进后台后,自定义 App 的未读数,如果不处理,App 未读数默认为所有会话未读数之和/// - Returns: 自定义未读数func onSetAPPUnreadCount() -> UInt32 {// 1. 获取自定义的角标var customBadgeNumber: UInt32 = 0 // ... 替换为你的自定义逻辑// 2. 加上 IM 的消息未读数customBadgeNumber += UInt32(self.unreadNumber)// 3. 通过 IMSDK 上报给 IM 服务器return customBadgeNumber}}
io.dcloud.PandoraEntry。
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);
文档反馈