tencent cloud

Chat

製品の説明
製品の概要
Basic Concepts
ユースケース
機能概要
アカウントシステム
ユーザープロフィールとリレーションシップチェーン
メッセージ管理
グループシステム
Official Account
Audio/Video Call
使用制限
購入ガイド
課金概要
価格説明
Purchase Instructions
Renewal Guide
支払い延滞説明
Refund Policy
ダウンロードセンター
SDK & Demo ソースコード
更新ログ
シナリオプラン
Live Streaming Setup Guide
AI Chatbot
極めて大規模なエンターテインメントコラボレーションコミュニティ
Discord実装ガイド
ゲーム内IM統合ガイド
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
クライアントAPIs
SDK API(Web)
Android
iOS & macOS
Swift
Flutter
SDK API(Electron)
SDK APIs (Unity)
SDK API(React Native)
C APIs
C++
サービス側 APIs
UserSigの生成
RESTful APIs
Webhooks
コンソールガイド
New Console Introduction
アプリケーションの作成とアップグレード
基本設定
機能設定
アカウント管理
グループ管理
Official Channel Management
コールバック設定
監視ダッシュボード
Viewing Guide for Resource Packages
Real-Time Monitor
補助ツールの開発
アクセス管理
Advanced Features
よくあるご質問
uni-app FAQs
 購入に関する質問
SDKに関する質問
アカウント認証に関する質問
ユーザープロファイルとリレーションシップチェーンに関する質問
メッセージに関する質問
グループに関する質問
ライブ配信グループに関する質問
ニックネームプロフィール画像に関連した問題
一般的なリファレンス
Service Level Agreement
セキュリティコンプライアンス認証
IM ポリシー
プライバシーポリシー
データプライバシーとセキュリティ契約
エラーコード
お問い合わせ

Custom Definition Badge

フォーカスモード
フォントサイズ
最終更新日: 2026-03-30 14:41:11
Android
iOS
Flutter
uni-app

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:
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.
Objective-C
Swift
// 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;
}

import ImSDK_Plus

class AppDelegate: UIResponder, UIApplicationDelegate, V2TIMAPNSListener, V2TIMConversationListener {
var unreadNumber: UInt64 = 0
// 1. Set the listener
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Listen for push notifications
V2TIMManager.sharedInstance()?.setAPNSListener(self)
// Listen for unread conversation counts
V2TIMManager.sharedInstance()?.setConversationListener(self)
return true
}
// 2. Save the unread count after it changes
func 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 count
func onSetAPPUnreadCount() -> UInt32 {
// 1. Get the custom-defined badge
var customBadgeNumber: UInt32 = 0
// 2. Add the IM message unread count
customBadgeNumber += UInt32(self.unreadNumber)
// 3. Report to the IM server via IMSDK
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 uni-app application is io.dcloud.PandoraEntry.




Step 2. Listen to changes in the total unread count of the Chat SDK to set the badge quantity.

1. Listen to the Chat SDK total unread message count updates through TOTAL_UNREAD_MESSAGE_COUNT_UPDATED.
2. Set the badge number through plus.runtime.setBadgeNumber.
let onTotalUnreadMessageCountUpdated = function(event) {
const unreadCount = event.data; // Total unread count of the current session
plus.runtime.setBadgeNumber(unreadCount); // Set the badge number
};
chat.on(TencentCloudChat.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED, onTotalUnreadMessageCountUpdated);

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック