Conversation List | Chat | Audio/Video Call |
![]() | ![]() | ![]() |
npx @tencent-rtc/trtc-agent-skills add --ide <your IDE> to install trtc-agent-skills in your local AI IDE (replace <your IDE> with cursor, codebuddy, claude, or codex, or use all to install for all of them) to assist with TUIKit integration. After installation, you can directly enter requests such as "Integrate Android Chat", "Add a custom message type", or "Switch between light and dark themes", and the AI will guide you through code integration, API calls, UI style changes, test data generation, and other steps based on your project type. For details, see Install Skills.git clone https://github.com/Tencent-RTC/TUIKit_Android_Compose.git
chat, call, and atomic_x folders from the repository root directory to your project root directory. The directory structure after copying is as follows:YourApplication/├── app/ # Your app module├── atomic_x/ # Basic UI component library├── call/ # Audio/video call component│ └── tuicallkit-kt/├── chat/ # Chat source code│ ├── demo/ # Demo project│ └── uikit/ # Chat Compose UIKit component library├── settings.gradle.kts└── build.gradle.kts
chat/ directory (chat/uikit is the Compose UIKit component library, and chat/demo is the demo project). The basic component atomic_x and the audio/video call component call/tuicallkit-kt that it depends on are located in the repository root directory. You can place the module directories anywhere in your project, as long as you set the correct relative paths in settings.gradle.kts.settings.gradle.kts (adjust the relative paths based on where you actually store the source code):// settings.gradle.ktsinclude(":atomic_x")project(":atomic_x").projectDir = file("${settingsDir.path}/atomic_x")include(":uikit")project(":uikit").projectDir = file("${settingsDir.path}/chat/uikit")include(":tuicallkit-kt")project(":tuicallkit-kt").projectDir = file("${settingsDir.path}/call/tuicallkit-kt")
// settings.gradleinclude ':atomic_x'project(':atomic_x').projectDir = new File(settingsDir, 'atomic_x')include ':uikit'project(':uikit').projectDir = new File(settingsDir, 'chat/uikit')include ':tuicallkit-kt'project(':tuicallkit-kt').projectDir = new File(settingsDir, 'call/tuicallkit-kt')
build.gradle.kts file in your project root directory (the uikit module depends on these two plugins; skip any plugin that is already declared). The plugin versions must match the Kotlin version used by your project:// build.gradle.kts (project root directory)plugins {id("org.jetbrains.kotlin.plugin.compose") version "2.0.21" apply falseid("org.jetbrains.kotlin.plugin.serialization") version "2.0.21" apply false}
// build.gradle (project root directory)plugins {id 'org.jetbrains.kotlin.plugin.compose' version '2.0.21' apply falseid 'org.jetbrains.kotlin.plugin.serialization' version '2.0.21' apply false}
build.gradle.kts file of the app module:// app/build.gradle.ktsplugins {id("com.android.application")id("org.jetbrains.kotlin.android")id("org.jetbrains.kotlin.plugin.compose")}android {compileSdk = 35 // >= 35defaultConfig {minSdk = 23 // >= 23}buildFeatures {compose = true}}dependencies {implementation(project(":atomic_x"))implementation(project(":uikit"))implementation(project(":tuicallkit-kt"))// Used to host ChatPage in an Activity via setContentimplementation("androidx.activity:activity-compose:1.10.1")}
// app/build.gradleplugins {id 'com.android.application'id 'org.jetbrains.kotlin.android'id 'org.jetbrains.kotlin.plugin.compose'}android {compileSdk 35 // >= 35defaultConfig {minSdk 21 // >= 21}buildFeatures {compose true}}dependencies {implementation project(':atomic_x')implementation project(':uikit')implementation project(':tuicallkit-kt')// Used to host ChatPage in an Activity via setContentimplementation 'androidx.activity:activity-compose:1.10.1'}

login API of LoginStore and pass in the sdkAppID, userID, and userSig obtained above for login authentication. After a successful login, initialize TUICallEngine (used for audio/video calls):import io.trtc.tuikit.atomicxcore.api.CompletionHandlerimport io.trtc.tuikit.atomicxcore.api.login.LoginStoreimport com.tencent.cloud.tuikit.engine.call.TUICallEngineimport com.tencent.cloud.tuikit.engine.common.TUICommonDefineLoginStore.shared.login(context,sdkAppID, // Int, obtained from the consoleuserID, // StringuserSig, // String, generated in the console or on your serverobject : CompletionHandler {override fun onSuccess() {// Login succeededTUICallEngine.createInstance(context).init(sdkAppID, userID, userSig,object : TUICommonDefine.Callback {override fun onSuccess() {// Initialization succeeded. Audio/video calls are available}override fun onError(errCode: Int, errMsg: String) {// Initialization failed}})}override fun onFailure(code: Int, desc: String) {// Login failed. You can display an error dialog}})
ChatPage to display, send, and receive messages. You only need to pass in conversationID. The format of conversationID is c2c_<peer UserID> for a one-to-one chat and group_<GroupID> for a group chat. The following example hosts ChatPage in an Activity via setContent. The Activity must be registered in AndroidManifest.xml:import android.content.Contextimport android.content.Intentimport android.os.Bundleimport androidx.activity.compose.setContentimport androidx.appcompat.app.AppCompatActivityimport io.trtc.tuikit.chat.uikit.pages.ChatPageclass ChatActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)// conversationID format: "c2c_<peer UserID>" for a one-to-one chat, "group_<GroupID>" for a group chatval conversationID = intent.getStringExtra("conversationID") ?: returnsetContent {ChatPage(conversationID = conversationID,onUserClick = { userID -> /* Click the avatar of the message sender */ },onChatHeaderClick = { /* Click the avatar in the title bar */ },onBackClick = { finish() })}}companion object {fun start(context: Context, conversationID: String) {context.startActivity(Intent(context, ChatActivity::class.java).apply {putExtra("conversationID", conversationID)})}}}
ChatActivity, a chat page encapsulated based on ChatPage (with a title bar, unread badge, group event handling, and more). You can reuse it directly or customize it based on its implementation: ChatActivity.start(context, conversationID).TUICallEngine after a successful login as described in Step 2, and you can then use audio/video calls in TUIKit components.com.tencentcloud.desk:aideskcustomer package as described in Integrating the Desk Customer Client on Android. You can then add customer service conversations to your app.int SDKAppID = 0; // The ID of the application for which Desk is activatedString userID = "";String userSig = "";// The above three parameters can be the same as those you use to log in to Tencent Cloud Chat, or you can use a different application and user// User nickname. After it is set, human agents can see it in the workbench when the customer is transferred to a human agent. You can include information such as the user's phone number and source in the nickname. The length limit is 500 bytes// Notice! After it is set, the nickname of the same userID in Chat is also updated// If you do not want it to change, set it to "" or nullString nickName = "";// User avatar. After it is set, human agents can see it in the workbench when the customer is transferred to a human agent// Notice! After it is set, the avatar of the same userID in Chat is also updated// If you do not want it to change, set it to "" or nullString avatar = "";TencentAiDeskCustomer.getInstance().initWithProfile(context, SDKAppID, userID, userSig, nickName, avatar, new AIDeskCallback() {@Overridepublic void onSuccess() {startActivity(TencentAiDeskCustomer.getInstance().getCustomerServiceChatIntent(context));}@Overridepublic void onError(int code, String desc) {}});
tuicallkit-kt dependency from settings.gradle.kts (or settings.gradle) and the build.gradle.kts (or build.gradle) file of the app module, delete the code that initializes TUICallEngine in Step 2, and disable the audio/video call switches in Step 3: Build the Chat UI, as shown below:import io.trtc.tuikit.chat.uikit.components.messageinput.config.ChatMessageInputConfigval messageInputConfig = ChatMessageInputConfig(isShowAudioCall = false, // Disable audio callsisShowVideoCall = false // Disable video calls)setContent {ChatPage(conversationID = conversationID,messageInputConfig = messageInputConfig,onUserClick = { },onChatHeaderClick = { },onBackClick = { finish() })}

Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários