Edition | Size | Feature Overview | Package Name |
Lite Edition | 200 KB | Initialization and event listening. Login and logout. Supports sending and receiving text messages. Supports custom message sending and receiving (customizable content). Supports user profile and user status. | @tencentcloud/lite-chat/basic |
Standard Edition (Default) | 516 KB | Includes all features of the Lite Edition, plus: Supports retrieving historical messages, message operations, merged forwarding, read receipts, message extension, and more. Supports sending and receiving image, video, audio, and file messages. Supports cloud message (Message) search, user (User) search, group (Group) search, and group member search. Supports conversation list, conversation profile, and conversation operations. Supports group management and group member management. Supports community. Supports AVChatRoom. | @tencentcloud/lite-chat |
Professional Edition | 609 KB | Includes all features of the Standard Edition, plus: Supports blacklist, friend management, friend grouping. Supports following and followers. Supports conversation grouping. Supports topics. | @tencentcloud/lite-chat/professional |
SDKAppID: The unique ID for your Chat application.SDKSecretKey: The SecretKey for your application.npm install @tencentcloud/lite-chat
// If you experience issues syncing dependencies, try switching the npm registry and retrynpm config set registry http://r.cnpmjs.org/
import TencentCloudChat from '@tencentcloud/lite-chat';
UserSig using your SDKAPPID and SECRETKEY.UserSig on your server. See Server-side UserSig Generation.example/chat/debug) and copy the contents of the debug folder into it.const { userSig } = genTestUserSig({SDKAPPID: 'your SDKAppID',SECRETKEY: 'Chat application SecretKey',userID: 'login userID',});
import TencentCloudChat from '@tencentcloud/lite-chat';let options = {SDKAppID: 0 // Replace 0 with your Chat application's SDKAppID};// Create SDK instance// Calling TencentCloudChat.create() with the same SDKAppID returns the same instance// The SDK instance is typically referenced as chatlet chat = TencentCloudChat.create(options);// Set SDK log level// 0: Development level, verbose logs, recommended during integration// 1: Production level, outputs essential SDK information, recommended for live environmentschat.setLogLevel(0);// chat.setLogLevel(1);
await chat.login({userID: 'your userID',userSig: 'your userSig', // userSig generated in step 1});
let message = chat.createTextMessage({to: 'userB',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: {text: 'Hello World!'},});await chat.sendMessage(message);
updateMyProfile.await chat.updateMyProfile({avatar: 'http(s)://url/to/image.jpg',});
followUser.await chat.followUser(['celebrity1', 'celebrity2', 'celebrity3']);// Retrieve your followers listawait chat.getMyFollowersList();
joinGroup to join an AVChatRoom, then use createTextMessage to create a message and sendMessage to post it.await chat.joinGroup({ groupID: 'group1' });let message = chat.createTextMessage({to: 'group1',conversationType: TencentCloudChat.TYPES.CONV_GROUP,payload: {text: 'AMAZING!!!'},});await chat.sendMessage(message);
피드백