tencent cloud

Chat

News and Announcements
Release Notes
Announcements
Product Introduction
Overview
Basic Concepts
Scenarios
Features
Account System
User Profile and Relationship Chain
Message Management
Group Related
Official Account
Audio/Video Call
Use Limits
Purchase Guide
Billing Overview
Pricing
Purchase Instructions
Renewal Guide
Service Suspension Explanation
Refund Policy
Development Guidelines
Demo Zone
Activate Service
Free Demos
Quick Run
Download
SDK and Demo Source Code
Update Log
Chat Interaction (UI Included)
TUIKit Introduction
Getting Started
Full-feature Integration
Single-function Integration
Build with AI
Build Basic Interfaces
More Features
Customizing Appearance
Internationalization
Push Service
Overview
Noun explanation
Activate the Service
Quick Start
Manufacturer Channel
Statistics
Troubleshooting Tool
Client APIs
REST API
Push Callback
Advanced Features
Release Notes
Error Codes
FAQS
Desk
Overview
Quick Start
Integration Guide
Admin Operation Manual
Agent Manual
More Practices
Live Streaming Setup Guide
AI Chatbot
Super Large Entertainment and Collaboration Community
Discord Implementation Guide
How to Integrate Chat into Games
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
No UI Integration
Quick Start
SDK Integration
Initialization
Login and Logout
Message
Conversation
Group
Community Topic
User Profile and Relationship Chain
Offline Push
Cloud Search
Local Search
Official Channel Management
Client APIs
JavaScript
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
Server APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
Console Guide
New Console Introduction
Creating and Upgrading an Application
Basic Configuration
Feature Configuration
Account Management
Group Management
Official Channel Management
Webhook Configuration
Usage
Viewing Guide for Resource Packages
Real-Time Monitor
Auxiliary Development Tools
Access Management
Advanced Features
FAQs
uni-app FAQs
Purchase
SDK
Account Authentication
User Profile and Relationship Chain
Message
Group
Audio-Video Group
Nickname and Profile Photo
Security Compliance Certification
Service Level Agreement
Security Compliance Certification
Chat Policies
Privacy Policy
Data Privacy and Security Agreement
Migration
Migration Solutions
Migration Solutions Lite
Error Codes
Contact Us

Unity

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-25 09:56:12

Overview

Starting from native SDK v7.0, Tencent Cloud Chat SDK provides the group counter feature. You can configure a certain number of counters for each group.
Unlike custom group attributes, group counters are used to store data of integer type. Group counters can be used to store additional information related to a group, such as the cumulative number of viewers, the number of views, the number of likes, and the number of gifts the audience has given to the host of an audio-video group.
Note:
Group counters support all types of groups, excluding topic-enabled community groups.
The group counter feature is supported only by the Pro edition 、Pro Plus edition or Enterprise edition.
Keep the following in mind for group counters:
1. A single group supports up to 20 group counters, that is, up to 20 keys per group.
2. For a single group counter, the key can contain up to 128 bytes, and the value must be of integer type (signed integer of up to 64 bits).
3. The GroupSetGroupCounters, GroupIncreaseGroupCounter, and GroupDecreaseGroupCounter APIs together can be called by a logged-in user up to 20 times every five seconds in the SDK, and the 8516 error code will be called back if the limit is exceeded.
4. The GroupGetGroupCounters API can be called by a logged-in user up to 20 times every five seconds in the SDK, and the 8516 error code will be called back if the limit is exceeded.


Setting Group Counters

Call the GroupSetGroupCounters (details) API to set group counters. After group counters are set, the GroupCounterChangedCallback (details) callback will be triggered. For the usage of the GroupCounterChangedCallback callback, see Group Counter Change Notification.
Note:
If the key of the group counter to be set already exists, the value of key is updated directly. Otherwise, a key-value pair will be added.
If multiple users set the same counter at the same time, the final value of the counter will be used. It's recommended that the group owner performs counter setting operations.
Sample: Call the GroupSetGroupCounters API to set the values of counters key1 and key2 to 0
// Set a group counter
List<GroupCounter> list = new List<GroupCounter>
{
new GroupCounter
{
group_counter_key = "key",
group_counter_value = 1
}
};
TIMResult res = TencentIMSDK.GroupSetGroupCounters("groupID", list, (int code, string desc, List<GroupCounter> results, string user_data)=>{
// Async result of the group counter setting
});


Incrementing the Value of a Group Counter

Call the GroupIncreaseGroupCounter (details) API to increment the value of a group counter. After the value of the group counter is incremented, the GroupCounterChangedCallback (details) callback will be triggered. For the usage of the GroupCounterChangedCallback callback, see Group Counter Change Notification.
Note:
The API parameter value is the change value. Each time when the API is called, the current value is incremented by the value passed in.
If the key of the group counter to be set already exists, the current value is directly incremented by the value passed in. Otherwise, a key will be added, and the default value (0) is incremented by the value passed in.
Sample: Assume that the current value of counter key1 is 8. After you call the GroupIncreaseGroupCounter API to pass in an increment value 2, the final value of key1 becomes 10.
// Increment the value of a group counter
TIMResult res = TencentIMSDK.GroupIncreaseGroupCounter("groupID", "key1", 2, (int code, string desc, List<GroupCounter> results, string user_data)=>{
// Async result of the group counter increment
});


Decrementing the Value of a Group Counter

Call the GroupDecreaseGroupCounter (details) API to decrement the value of a group counter. After the value of the group counter is decremented, the GroupCounterChangedCallback (details) callback will be triggered. For the usage of the GroupCounterChangedCallback callback, see Group Counter Change Notification.
Note:
The API parameter value is the change value. Each time when the API is called, the current value is decreased by the value passed in.
If the key of the group counter to be set already exists, the current value is directly decremented by the value passed in. Otherwise, a key will be added, and the default value (0) is decreased by the value passed in.
Sample: Assume that the current value of counter key1 is 8. After you call the GroupDecreaseGroupCounter API to pass in a decrement value 2, the final value of key1 becomes 6.
// Decrement the value of a group counter
TIMResult res = TencentIMSDK.GroupDecreaseGroupCounter("groupID", "key1", 2, (int code, string desc, List<GroupCounter> results, string user_data)=>{
// Async result of the group counter decrement
});


Getting Group Counters

Call the GroupGetGroupCounters (details) API to pass in a set of keys to get the information of the corresponding group counters. The API will return all key-value pairs matching the keys passed in.
Note:
If the key list passed in is empty, all group counters are returned.
Sample: Call the GroupGetGroupCounters`` API to get the values of counters key1 and key2`
// Get group counters
TIMResult res = TencentIMSDK.GroupGetGroupCounters("groupID", new List<string> {"key1", "key2"}, (int code, string desc, List<GroupCounter> results, string user_data)=>{
// Async result of the group counter getting
});


Group Counter Change Notification

When you call the GroupSetGroupCounters, GroupIncreaseGroupCounter, or GroupDecreaseGroupCounter API to modify group counters, the SDK will trigger the GroupCounterChangedCallback callback and return the updated values of value.
Note:
Before you can invoke the above-mentioned callback, you need to call the SetGroupCounterChangedCallback (details) API to add a group listener.
Sample code:
// Set the group counter change callback
TencentIMSDK.SetGroupCounterChangedCallback((string group_id, string group_counter_key, ulong group_counter_new_value, string user_data) => {
});


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백