TUIKit and successfully sending your first message.SDKAppID and SDKSecretKey, then proceed to the next section.


SDKAppID and SDKSecretKey in the console overview panel. You will need both to run the Demo.
SDKSecretKey to protect your Application from unauthorized access.


login API of LoginStore to log in to a user account. There are two cases:// API location: io.trtc.tuikit.atomicxcore.api.login.LoginStoreLoginStore.shared.login(activity, // Activity contextsdkAppID, // Int, SDK application IDuserID, // String, User IDuserSig, // String, User signatureobject : CompletionHandler {override fun onSuccess() {// Login success}override fun onFailure(code: Int, desc: String) {// Login failed}})
sdkAppID, the sdkAppID obtained above.senderUserID, the userID of the message sender, that is, user1 above.senderUserSig, the userSig obtained above for the message sender.receiverUserID, the userID of the message receiver.import android.os.Bundleimport android.view.ViewGroupimport android.widget.FrameLayoutimport androidx.appcompat.app.AppCompatActivityimport androidx.core.view.ViewCompatimport androidx.core.view.WindowCompatimport androidx.core.view.WindowInsetsCompatimport androidx.core.view.updatePaddingimport io.trtc.tuikit.atomicxcore.api.CompletionHandlerimport io.trtc.tuikit.atomicxcore.api.login.LoginStoreimport io.trtc.tuikit.chat.uikit.pages.ChatPageViewclass ChatPageDemoActivity : AppCompatActivity() {private val sdkAppID: Int = 0 // TODOprivate val senderUserID = "" // TODOprivate val senderUserSig = "" // TODOprivate val receiverUserID = "" // TODOprivate val conversationID: String get() = "c2c_${receiverUserID}"private var chatPageView: ChatPageView? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)WindowCompat.setDecorFitsSystemWindows(window, false)LoginStore.shared.login(this, sdkAppID, senderUserID, senderUserSig, object : CompletionHandler {override fun onSuccess() = showChatPage()override fun onFailure(code: Int, desc: String) {}})}private fun showChatPage() {val container = FrameLayout(this).apply {layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)}ViewCompat.setOnApplyWindowInsetsListener(container) { view, insets ->val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())view.updatePadding(top = bars.top, bottom = bars.bottom)insets}setContentView(container)val page = ChatPageView(this)container.addView(page)page.setup(conversationID = conversationID,onUserClick = { /* Handle user avatar click */ })chatPageView = page}override fun onDestroy() {chatPageView?.release()super.onDestroy()}}

Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan