Run Demo

This document mainly describes how to quickly run the Chat Demo.

Environment Requirements

Xcode 10 or later
iOS 9.0 or later
CocoaPods 1.7.5 or later

Steps

1. Create an App

1. Log in to the Tencent RTC Console. If you already have an application, record its SDKAppID and SDKSecretKey and jump directly to the next section.
2. Click Create Application, enter your Application name, product, Region, and click Create.


2. Obtain SDKAppID and SDKSecretKey

After creation, you can view the newly created app's Status, SDKAppID, Expiration time, etc., on the Console Overview Page:



Record the SDKAppID and SDKSecretKey from the Application Information.
Warning:
Store the SDKSecretKey securely to prevent leakage.

3. Download and Configure the Demo Source Code

Note:
To respect the copyright of emoji designs, the Chat Demo/TUIKit project does not include cutouts of large emoji elements. Please replace them with your own designs or other emoji packs for which you hold the copyright before officially launching for commercial use. The default smiley face emoji pack shown below is copyrighted by Tencent RTC, you can upgrade to Chat Pro Plus Edition and Enterprise Edition to use it for free.




Download Swift Demo

2. Navigate to the project directory and open the project to find the GenerateTestUserSig.swift file.
iOS path: Chat_UIKit/Swift/TUIKitDemo/TUIKitDemo/Private/GenerateTestUserSig.swift
3. Set the relevant parameters in the GenerateTestUserSig.swift file:
Set public_SDKAPPID to the actual SDKAppID obtained in Step 1.
Set public_SECRETKEY to the actual key information obtained in Step 2.

Download Objective-C Demo

1. Download the iOS demo project from Github.
2. Navigate to the project directory in your terminal and find the GenerateTestUserSig.h file. The path is: chat-uikit-ios-main/Demo/TUIKitDemo/Private/GenerateTestUserSig.h
3. Set the relevant parameters:
SDKAPPID: the SDKAppID obtained above.
SECRETKEY: the SDKSecretKey obtained above.

Warning:
1. In this document, the method to obtain UserSig is to configure a SECRETKEY in the client code. In this method, the SECRETKEY is vulnerable to decompilation and reverse engineering. Once your SECRETKEY is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, this method is only suitable for locally running a demo project and debugging feature.
2. The correct UserSig distribution method is to integrate the calculation code of UserSig into your server and provide an API for your app. When UserSig is needed, your app can send a request to the business server to obtain a dynamic UserSig. For more information, see How to Generate UserSig on the Server.
3. To respect the copyright of emoji design, the downloaded demo project does not contain sliced images of major emoji elements. You can use your local emoji packs to configure code. Unauthorized use of the emoji pack in the Chat demo may infringe on the design copyright.

4. Compile and Run the Demo

See the file README.md in the corresponding directory of the demo project cloned above.
1. Run the following command on the terminal to check the pod version:
pod --version
If the system shows that no pod exists or that the pod version is earlier than 1.7.5, run the following commands to install the latest pod.
//Install pod
sudo gem install cocoapods -n /usr/local/bin
// If multiple versions of Xcode are installed, run the following command to choose an Xcode version (usually the latest one):
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
//Update Pod Local Repository
pod setup
2. Run the following commands in the terminal to open the directory containing the Podfile and install dependencies:
Swift
Objective-C
cd Swift/TUIKitDemo
pod install
cd chat-uikit-ios-main/Demo
pod install
If installation fails, run the following command to update the local CocoaPods repository list:
pod repo update
3. Compile and run the demo:
For a Swift project, navigate to the Swift/TUIKitDemo folder, open TUIKitDemo.xcworkspace, then compile and run.
For an Objective-C project, navigate to the chat-uikit-ios-main/Demo folder, open TUIKitDemo.xcworkspace, then compile and run.
Note:
The demo includes the TRTC call feature by default. However, the TRTC SDK on which this feature relies currently does not support simulators. Please use a real device for debugging or running the demo.

Experience basic features

Create User Account

If you have successfully run the Demo by following the above steps, you can start experiencing the basic features.
First, you need to create a user account. There are many ways to do this, for example, by logging in to the demo on the client side to register or by creating it in the console. You can choose any method that suits you.
Client Registration
Simply log in to the Demo with several different accounts.
Console Create
The steps are as follows:
1. Click to enter the application you created above, and you will see the Chat product entry on the left sidebar, click to enter.
2. After entering the Chat product subpage, click on Users to access the User Management Page.
3. Click Create account to open a pop-up where you can fill in account creation details. If you are a regular member, we recommend choosing the General type. Although Nickname is not mandatory, we still suggest setting it. If displaying userID on the interface is inconvenient, you can identify different users by their Nickname.
The details are as follows:

Note:
Sending messages involves at least two users, so you need to create at least two accounts at this step. Please note down the userID of these two accounts for subsequent steps.

Add Contact

After switching to the Contacts interface:
1. Click the + button in the top right corner of the interface, and in the submenu, select Add to Contacts.
2. Enter a valid userID and search for the user. If you have already created an account in the console, you can go to the console Account Management page to get a valid userID. Page path: Applications > Your App > Chat > Users > Account Management.
3. Add user as a contact.
The steps are shown below:
Click [Add to Contacts]
Search for a user
Send a contact request









After successfully adding, the user will appear in the contact list:


Sending Messages

Select a user, click on the Message to enter the message interface:



Next, you can send messages, voice messages, images, and make audio/video calls with the user in the message interface: