If you encounter problems during access or use, please refer to FAQ.
Steps
Step 1: Enabling the Service
Please see Activate the service. to claim the experience edition or activate the paid edition.
Step 2: Downloading the TUILiveKit Component
Use CocoaPods to import components. If you encounter problems, please first refer to Environment Preparation. The specific steps to import components are as follows:
1. Add pod 'TUILiveKit' dependency in your Podfile file. If you encounter any issues, please refer to the example project.
target 'xxxx'do
...
...
pod 'TUILiveKit'
end
If you do not have a Podfile file, first cd to the xxxx.xcodeproj directory in the terminal, then create it through the following command:
pod init
2. In the terminal, first cd to the Podfile directory, then execute the following commands to install components.
pod install
If you cannot install the latest version of TUILiveKit, first delete Podfile.lock and Pods. Then execute the following commands to update the local CocoaPods repository list.
pod repo update
Then perform the following command to update the Pod version of the component library.
pod update
3. Compile and run the project. If you encounter any issues, refer to the FAQ. If the problem still can't be solved, you can try running our example project first. We also welcome any feedback on issues you encounter during the integration process.
Step 3: Project Configuration
To use the audio and video feature, authorization is required for permission to use the microphone and camera. In App's Info, add the following two items, respectively corresponding to the prompt message when the system pops up the authorization dialog for the microphone and camera.
<key>NSCameraUsageDescription</key>
<string>TUILiveKit needs to access your camera permission. Video recording with picture only after enabling</string>
<key>NSMicrophoneUsageDescription</key>
<string>TUILiveKit needs to access your mic permission. Recorded video will have sound when enabled</string>
Step 4: Logging In
Add the following code in your project. It enables logging in to the TUI component by calling relevant APIs in TUICore. This step is critical because only after successful log-in can you properly use TUILiveKit features. Please check if the related parameters are configured correctly.
Here is a detailed introduction to the key parameters needed in the login function:
SDKAppID: Obtained in the last step in Step 1 and not detailed here.
UserID: The ID of the current user, which is a string that can contain only letters (a–z and A–Z), digits (0–9), hyphens (-), or underscores (_).
UserSig: The authentication credential used by Tencent Cloud to verify whether the current user is allowed to use the TRTC service. You can get it by using the SDKSecretKey to encrypt the information such as SDKAppID and UserID. You can generate a temporary UserSig on the UserSig Tools page in the console.
This procedure is currently the one with the most developer feedback. Common issues are as follows:
SDKAppID configuration error. The SDKAppID for the domestic site is normally a 10-digit integer starting with 140.
userSig is mismatched with the encryption key (Secretkey). userSig is generated by encrypting SDKAppID, userID, and expiration time with the Secretkey, rather than directly configuring the Secretkey as userSig.
**Note:** The userID is set to simple strings such as "1", "123", or "111". Since TRTC does not support the same UserID for multi-end login, in collaborative development, userIDs like "1", "123", or "111" can easily be occupied by your colleagues, leading to login failure. Therefore, we recommend setting highly recognizable userIDs during debugging.
Note: The example code on Github uses the genTestUserSig function to calculate userSig locally for faster access process. However, this solution will expose your SecretKey in the App code, which is not conducive to subsequent upgrades and protection of your SecretKey. Therefore, we strongly recommend performing the computation logic of userSig on the server and requesting real-time computed userSig from your server each time the TUILiveKit component is used.