UserSig
in the console as shown below:UserID
of administrator
. You can also create multiple admin accounts as needed. Note that you can create up to five admin accounts.Basic Information | Other Information |
Username, gender, date of birth, level, role, mobile number, etc. | Other information required by games |
Item | Chat | Business Background |
Storage capacity | Supports automatic scaling | Supports limited capacity and difficult to scale |
User profiles | Supports standard and custom fields, with restrictions on the lengths and names of the fields | Customizable, more flexible |
Profile read/write | Supports easy-to-use service APIs and guidelines | Requires development on your own |
APIs | Requires the API call frequency to be 200 times/second or less | Allows you to develop API call and other capabilities as needed |
Security | Supports remote disaster recovery and cross-region deployment | Requires maintenance on your own |
Key-Value
format. Key
is of the String
type and supports only uppercase and lowercase letters, digits, and underscores. Value
supports the following types:Type | Description |
uint64_t | Integer (Not supported by custom fields.) |
string | String. The string length cannot exceed 500 bytes. |
bytes | Buffer. The buffer length cannot exceed 500 bytes. |
string array | String array. Each string cannot exceed 500 bytes. Available only to the Tag_SNS_IM_Group field of the friend list. |
Field Name | Type | Description |
Tag_SNS_IM_Group | Array | Friend list |
Tag_SNS_IM_Remark | String | Friend remarks |
Tag_SNS_IM_AddSource | String | Source of the friend request |
Tag_SNS_IM_AddWording | String | Content of the friend request |
Tag_SNS_IM_AddTime | Integer | Timestamp of the friend request |
// Configure the message receiving event listenerTencentIMSDK.AddRecvNewMsgCallback((List<Message> messages, string user_data)=>{foreach(Message message in messages){foreach (Elem elem in message.message_elem_array){// There is a next elementif (elem.elem_type == TIMElemType.kTIMElem_Text){string text = elem.text_elem_content;}}}})// Listen for the `RecvNewMsgCallback` callback to receive messages// To stop receiving messages, call `RemoveRecvNewMsgCallback` to remove the listener. This step is optional and can be performed as needed.
API | Characteristics | Application Scenarios |
Sends a message to a specified account. The sender displayed to the recipient is not the admin, but the account specified by the admin. | Sending messages to a specific user, for example, sending a game rewarding message to a user | |
A one-to-one message can be sent to up to 500 users at a time, and the highest call frequency is 200 times per second. | Sending messages to specific users, without the need to create a recipient group. If the number of recipients is large, you need to send the messages in batches. | |
When sending ordinary messages to a group, you need to add all recipients to the same group. | Sending ordinary messages to a large number of users (up to 100,000 users per community group) | |
Pushes messages to all users in an app. You can specify user tags and attributes for message sending. | Pushing messages to all users in an app or to a large number of users with specific characteristic attributes, such as campaign emails |
{"GroupId": "@TGS#2C5SZEAEF","Random": 8912345, // A random number. If the random numbers of two messages are the same within five minutes, they are considered to be the same message."MsgBody": [ // Message body, which consists of an element array. For details, see the field description.{"MsgType": "TIMTextElem", // Text"MsgContent":{"Text": "red packet"}},{"MsgType": "TIMCustomElem", // Custom"MsgContent":{"Data": "message","Desc": "notification","Ext": "url","Sound":"dingdong.aiff"}}],}
MsgBody
(message body) is a message array. You can add text and custom messages to be sent to it.// Pull historical one-to-one messages// Set `msg_getmsglist_param_last_msg` to `null` for the first pull// `msg_getmsglist_param_last_msg` can be the last message in the returned message list for the second pull.var get_message_list_param = new MsgGetMsgListParam{msg_getmsglist_param_last_msg = LastMessage};TIMResult res = TencentIMSDK.MsgGetMsgList(conv_id, TIMConvType.kTIMConv_C2C, get_message_list_param, (int code, string desc, string user_data) => {// Process the callback logic});
// Get the total unread countTIMResult res = TencentIMSDK.ConvGetTotalUnreadMessageCount((int code, string desc, GetTotalUnreadNumberResult unread, string user_data)=>{// Process the async logic});// Unread count change notificationTencentIMSDK.SetConvTotalUnreadMessageCountChangedCallback((int total_unread_count, string user_data)=>{// Process the callback logic});// Clear the unread count of all conversationsTIMResult res = TencentIMSDK.MsgMarkAllMessageAsRead((int code, string desc, string user_data)=>{// Process the async logic});
https://console.tim.qq.com/v4/all_member_push/im_push?usersig=xxx&identifier=admin&sdkappid=88888888&random=99999999&contenttype=json
{"From_Account": "admin","MsgRandom": 56512,"MsgLifeTime": 120, // Offline storage for 120s (two minutes)"MsgBody":[{"MsgType": "TIMTextElem","MsgContent":{"Text": "hi, beauty"}}]}
MsgLifeTime
(unit: second) to specify the offline storage period: The maximum period is 604,800 seconds (seven days). The default value is 0
, which indicates that messages are not stored offline.MsgLifeTime
to specify the offline storage period (up to seven days) of the message. If MsgLifeTime
is 0
, it indicates that the message is sent to online users only and is not stored offline. For more information, see here.https://console.tim.qq.com/v4/group_open_http_svc/create_group?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
{"Owner_Account": "leckie", // UserId of the group owner (optional)"Type": "Public", // Group type: Private, Public, ChatRoom, AVChatRoom, or Community"Name": "TestGroup", // Group name (required)"MaxMemberCount":5 // Maximum number of group members (optional)}
https://console.tim.qq.com/v4/group_open_http_svc/add_group_member?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
{"GroupId": "@TGS#2J4SZEAEL", // The group to which to add members (required)"MemberList": [ // Up to 300 members can be added at a time.{"Member_Account": "tommy" // The ID of the member to be added (required)},{"Member_Account": "jared"}]}
webhook after a group is full
is received, the game can be started. The following is a sample request URL:https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json&ClientIP=$ClientIP&OptPlatform=$OptPlatform
{"CallbackCommand": "Group.CallbackAfterGroupFull", // Webhook command"GroupId": "@TGS#2J4SZEAEL" // Group ID}
webhook after a user joins a group
to notify other group members. The following is a sample request URL:https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json&ClientIP=$ClientIP&OptPlatform=$OptPlatform
{"CallbackCommand": "Group.CallbackAfterNewMemberJoin", // Webhook command"GroupId" : "@TGS#2J4SZEAEL","Type": "Public", // Group type"JoinType": "Apply", // Group joining method: `Apply` (application); `Invited` (invitation)"Operator_Account": "leckie", // Operator"NewMemberList": [ // List of new members{"Member_Account": "jared"},{"Member_Account": "tommy}]}
webhook after a user leaves a group
and can also send a message to the player who leaves the game due to network problems. The following is a request URL example for After a User Leaves a Group:https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json&ClientIP=$ClientIP&OptPlatform=$OptPlatform
{"CallbackCommand": "Group.CallbackAfterMemberExit", // Webhook command"GroupId": "@TGS#2J4SZEAEL", // Group ID"Type": "Public", // Group type"ExitType": "Kicked", // Member leaving type: `Kicked` - being kicked out; `Quit` - voluntarily leaving"Operator_Account": "leckie", // Operator"ExitMemberList": [ // List of members who left the group{"Member_Account": "jared"},{"Member_Account": "tommy"}]}
https://console.tim.qq.com/v4/group_open_http_svc/destroy_group?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
{"GroupId": "@TGS#2J4SZEAEL"}
Getting Group Profiles
to get group details such as the number of members in the group and the basic information of the group members. You can use the Filter
field in the request to filter the information to pull. The following is a sample request URL:https://console.tim.qq.com/v4/group_open_http_svc/get_group_info?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
{"GroupIdList": [ // The list of group IDs specified for the query. This parameter is required."@TGS#1NVTZEAE4","@TGS#1CXTZEAET"]}
Getting Group Member Profiles
to get the detailed information of group members (including custom fields). The following is a sample request URL:https://console.tim.qq.com/v4/group_open_http_svc/get_group_member_info?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
{"GroupId":"@TGS#1NVTZEAE4" // Group ID (required)}
MemberNum
field indicates the total number of members in the group, and AppMemberDefinedData
indicates the custom field information of group members.Getting Group Member Profiles
to get the detailed information, such as role and status, of other members in the team.GroupGetMemberInfoListParam param = new GroupGetMemberInfoListParam{group_get_members_info_list_param_group_id = "group_id",group_get_members_info_list_param_identifier_array = new List<string>{"user_id"}};TIMResult res = TencentIMSDK.GroupGetMemberInfoList(param, (int code, string desc, GroupGetMemberInfoListResult result, string user_data)=>{// Process the async logic});
{"CallbackCommand": "Group.CallbackBeforeSendMsg", // Webhook command"GroupId": "@TGS#2J4SZEAEL", // Group ID"Type": "Public", // Group type"From_Account": "jared", // Sender"Operator_Account":"admin", // Request initiator"Random": 123456, // Random number"OnlineOnlyFlag": 1, // The value is `1` if it is an online message and `0` (default) if it’s not. For audio-video groups, the value is `0`."MsgBody": [ // Message body. For more information, see the `TIMMessage` message object.{"MsgType": "TIMTextElem", // Text"MsgContent":{"Text": "red packet"}}],"CloudCustomData": "your cloud custom data"}
MsgType
field in MsgBody
. For more information on the fields, see Before a Group Message Is Sent.{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0 // Different `ErrorCode` values have different meanings.}
ErrorCode | Description |
0 | Speaking is allowed, and messages can be delivered normally. |
1 | Speaking is rejected, and the client returns 10016 . |
2 | Silent discarding is enabled, and the client returns messages normally. |
{"GroupId": "@TGS#2C5SZEAEF","Random": 8912345, // A random number. If the random numbers of two messages are the same within five minutes, they are considered to be the same message."MsgBody": [ // Message body, which consists of an element array. For details, see the field description.{"MsgType": "TIMTextElem", // Text"MsgContent":{"Text": "red packet"}},{"MsgType": "TIMFaceElem", // Emoji"MsgContent":{"Index": 6,"Data": "abc\\u0000\\u0001"}}],"CloudCustomData": "your cloud custom data","SupportMessageExtension": 0,}
CloudCustomData
to define the custom message data (stored on the cloud) and enter the custom message in MsgBody
(message body) for sending.Type | Characteristics |
Channel | A channel usually engages a large number of chat users and does not have a list of fixed members. Users can join and leave a channel at any time. Offline message push is not required. |
Live game lobby | A live game lobby usually engages a number of chat users. Users can join and leave the live room at any time. Historical message query is supported. |
Team | A team usually engages a small number of chat users, who do not need to be friends with each other. A team is terminated when a game ends. Offline message push is not required. |
Friend | One-to-one chat. Chat records are stored. Chat partners can only be friends in the contact list. |
Private message | One-to-one chat. Chat partners can be strangers. |
Audio-video group | There is no limit on the number of chat users. Users can join and leave an audio-video group at any time. |
Type | Characteristics |
Work group (Work) | A work group allows users to join the group by being invited by a friend who is a member of the group. The invitation does not need to be accepted by the invitee or approved by the group owner. |
Public group (Public) | A public group allows the group owner to designate group admins. To join the group, a user needs to search for the group ID and send a request, and the request needs to be approved by the group owner or an admin before the user can join the group. |
Meeting group (Meeting) | A meeting group allows users to join and leave freely and view historical messages sent before they join the group. Meeting groups are ideal for scenarios that integrate Tencent Real-Time Communication (TRTC), such as audio/video conferencing and online education. This group type is the same as chat room (ChatRoom) in earlier versions. |
Audio-video group (AVChatRoom) | An audio-video group allows users to join and exit freely, supports an unlimited number of members, and does not store message history. Audio-video groups can be used with Cloud Streaming Services (CSS) to support on-screen comment chat scenarios. |
Community group (Community) | A community group allows users to join and exit freely, supports up to 100,000 members, and stores message history. To join the group, a user needs to search for the group ID and send an application, and the application does not need to be approved by an admin before the user can join the group. |
Type | Solution | Characteristics |
Channel and live game lobby | Community group | A community group supports a large number of users and allows users to join and leave freely, without approval. |
Friend | One-to-one chat+Permission control (allowing only friends to send messages to each other) | Only friends are allowed to send messages to each other. |
Private message | One-to-one chat+Permission control (allowing any two users in the app to send one-to-one messages to each other) | Any two strangers can send messages to each other. |
Team-up | Public group (Public) and meeting group (Meeting) | Only team members in the game can enter the group chat. Audio-video chat is supported. |
Audio-video group | Audio-video group (AVChatRoom) | There is no limit on the number of group members, and users can join or leave an audio-video group at any time. |
Was this page helpful?