chat-uikit-react is a react UI component library based on Tencent Cloud Chat SDK. It provides some common UI components, including features for conversation, chat, and group. Based on the well-designed UI components, you can quickly build elegant, reliable, and scalable Chat applications. The interface of chat-uikit-react is shown in the figure below:
After the project is created, go to the project directory.
cd sample-chat
Step 2: Download the chat-uikit-react component
Use npm to download chat-uikit-react and use it in your project. Additionally, related open source code is also provided on GitHub, which you can use as a basis to develop your own component library.
npminstall @tencentcloud/chat-uikit-react
Step 3: Include the chat-uikit-react component
Note:
In the following code, SDKAppID, userID, and userSig are not input. Acquire the necessary information in Step 4 and replace it accordingly.
npm Integration Method
Source Code Integration Method
Replace the content in App.tsx, or you can create a new component for inclusion.
2. Click Create Application, enter your application name, and then click Create.
3. After creation is complete, you can view the status, service version, SDKAppID, creation time, tag, and expiration time of the new application on the console overview page.
Step 5: Obtain userID and userSig
userID
Click to enter the Application you created above. You will see the Chat product entrance in the left sidebar. Click to enter.
After entering the Chat Product subpage, click on Users to go to the User Management Page.
Click Create account, a form for creating account information will pop up. If you are just a regular member, we recommend you choose the General type.
To enhance your experience with message sending and receiving features, we recommend creating two userIDs.
1. After starting the project, click + on the left to start a one-to-one chat.
2. Enter the userID created in Step 5 in the search box, and then press Enter.
3. Enter your message in the input box and press Enter to send.
FAQs
What is UserSig?
A UserSig is a cipher with which you can log in to Chat. It is the ciphertext generated by encrypting information such as userID.
How can I generate a UserSig?
The issuance method for UserSig involves integrating the computation code of UserSig into your server, and providing an API oriented towards your project. When UserSig is needed, your project sends a request to the business server to obtain the dynamic UserSig. For more information, see How to Generate a UserSig on the Server.
Note:
The sample code provided in this document retrieves the UserSig by embedding the secret key in the client code. This approach makes the secret key highly susceptible to decompilation and reverse engineering. Once your key is compromised, attackers can misappropriate your Tencent Cloud traffic. Hence, this approach is exclusively recommended for debugging features locally. For the correct issuance of UserSig, please refer to the previous sections.