tencent cloud

Feedback

Last updated: 2024-05-31 16:42:21
    This article will guide you through the quick integration of the TUICallKit component. You will complete several key steps within 10 minutes, ultimately obtaining a video call feature with a complete UI interface.
    1v1 Video Call
    Group call
    
    
    
    
    
    

    Environment Preparations

    Android 5.0 (SDK API level 21) or later.
    Gradle 4.2.1 or later
    Mobile phone on Android 5.0 or later.

    Step 1. Activate the service

    Before using the Audio and Video Services provided by Tencent Cloud, you need to go to the Console and activate the service for your application. For detailed steps, refer to Activate Service. Please record the SDKAppID and SDKSecretKey, they will be used for the following steps.

    Step 2. Download and import the component

    Go to GitHub, clone or download the code, and copy the tuicallkit-kt subdirectory in the Android directory to the directory at the same level as app in your current project, as shown below.
    

    Step 3. Configure the project

    1. Find the settings.gradle.kts(or settings.gradle) file in the project root directory and add the following code to import the tuicallkit-kt component.
    setting.gradle.kts
    settings.gradle
    include(":tuicallkit-kt")
    include ':tuicallkit-kt'
    2. Find the build.gradle.kts(or build.gradle) file in the app directory, add the following code to its dependencies section. This is to declare the current app's dependency on the newly added components.
    build.gradle.kts
    build.gradle
    dependencies {
    api(project(":tuicallkit-kt"))
    }
    dependencies {
    api project(':tuicallkit-kt')
    }
    Note:
    The TUICallKit project depends on TRTC SDK, Chat SDK, tuicallengine, and the tuicore public library internally by default. To upgrade the version, modify the version in tuicallkit-kt/build.gradle file.
    3. Since the SDK uses Java's reflection feature internally, you need to add certain classes in the SDK to the obfuscation allowlist. Therefore, you should add the following code to the proguard-rules.pro file in the app directory. After adding, click on the upper right corner "Sync Now" to synchronize the code.
    -keep class com.tencent.** { *; }
    4. In the app directory, find the AndroidManifest.xml file and add tools:replace="android:allowBackup" within the application node to override the settings inside the components, using your own settings.
    // app/src/main/AndroidManifest.xml
    <application android:name=".DemoApplication" android:allowBackup="false" android:icon="@drawable/app_ic_launcher" android:label="@string/app_name" android:largeHeap="true" android:theme="@style/AppTheme" tools:replace="android:allowBackup">
    5. We suggest you compile and run once. If you encounter any issues, you may try our Github demo. By comparison, you can identify potential differences and resolve encountered issues. During integration and use, if any issues arise, you are welcome to provide feedback to us.

    Step 4. Log in to the TUICallKit component

    Add the following code to your project. It works by calling the relevant interfaces in TUICore to complete the login to TUI Component. This step is very important, only after successfully logging in, you can normally use the features offered by TUICallKit.
    Kotlin
    Java
    import com.tencent.qcloud.tuicore.TUILogin import com.tencent.qcloud.tuicore.interfaces.TUICallback
    import com.tencent.qcloud.tuikit.tuicallkit.debug.GenerateTestUserSig
    
    class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)
    
    // begin
    val userID = "denny" // Please replace with your UserId
    val sdkAppID = 0 // Please replace with the SDKAppID obtained from the console in step 1
    val secretKey = "****" // Please replace with the SecretKey obtained from the console in step 1
    val userSig = GenerateTestUserSig.genTestUserSig(userId, sdkAppId, secretKey)
    TUILogin.login(this, sdkAppId, userId, userSig, object : TUICallback() {
    override fun onSuccess() {
    }
    override fun onError(errorCode: Int, errorMessage: String) {
    }
    })
    // end } }
    import com.tencent.qcloud.tuicore.TUILogin; import com.tencent.qcloud.tuicore.interfaces.TUICallback;
    import com.tencent.qcloud.tuikit.tuicallkit.debug.GenerateTestUserSig;
    
    public class MainActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
    
    //begin
    String userID = "denny"; // Please replace with your UserId
    int sdkAppID = 0; // Please replace with the SDKAppID obtained from the console in step 1
    String secretKey = "****"; // Please replace with the SecretKey obtained from the console in step 1
    String userSig = GenerateTestUserSig.genTestUserSig(userId, sdkAppId, secretKey);
    TUILogin.login(this, sdkAppId, userId, userSig, new TUICallback() {
    @Override
    public void onSuccess() {
    }
    @Override
    public void onError(int errorCode, String errorMessage) {
    }
    });
    //end } }
    Parameter
    Type
    Description
    userID
    String
    your own User ID based on your business. It can only include letters (a-z, A-Z), digits (0-9), underscores, and hyphens.
    sdkAppID
    int
    The unique identifier SDKAppID for the audio and video application created in Tencent RTC Console.
    secretKey
    String
    SDKSecretKey for the audio and video application created in Tencent RTC Console.
    userSig
    String
    A security signature for user login to verify identity and prevent unauthorized access to cloud services.
    Note:
    Development Environment: During local development and debugging, use the local GenerateTestUserSig.genTestSig function to create a userSig. But be careful, the SDKSecretKey can be decompiled and reverse-engineered. If leaked, it could allow theft of your Tencent Cloud traffic.
    Production Environment: If your project is going to be launched, please adopt the method of Server-side Generation of UserSig.

    Step 5. Make your first phone call

    After user login success, invoke the call method of TUICallKit, specifying the callee's userID and the type of call, to initiate an audio/video call. The callee will receive an incoming call invitation.
    Kotlin
    Java
    import com.tencent.qcloud.tuikit.tuicallengine.TUICallDefine
    import com.tencent.qcloud.tuikit.tuicallkit.TUICallKit
    
    // Initiating a one-to-one audio call (assuming the callee's userID is mike)
    TUICallKit.createInstance(context).call("mike", TUICallDefine.MediaType.Audio)
    import com.tencent.qcloud.tuikit.tuicallengine.TUICallDefine;
    import com.tencent.qcloud.tuikit.tuicallkit.TUICallKit;
    
    // Initiating a one-to-one audio call (assuming the callee's userID is mike)
    TUICallKit.createInstance(context).call("mike", TUICallDefine.MediaType.Audio);
    Caller initiates an audio call
    Callee receives an audio call request
    
    
    
    
    
    

    

    Additional Features

    FAQs

    If you encounter any issues during integration and use, please refer to Frequently Asked Questions.

    Suggestions and Feedback

    If you have any suggestions or feedback, please contact info_rtc@tencent.com.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support