logo
On this page

Message component

The message component of the In-app Chat Kit provides the message list and message transmission features.

Note
If you don't need the Conversation List, you can directly use the message component.
  • Message list: Allow you to view the message history of a chat.
  • Message transmission: Allow you to send or receive one-to-one messages and group messages.

Integrate the message component into your project

Prerequisites

Integrate the In-app Chat Kit SDK into your project (finished the initialization and login are required). For more information, see Quick start.

Show the message component

In-app Chat Kit allows you to integrate the message component into your Activity as an Activity or a Fragment.

Warning
  • For the Activity mode, the title bar and the button for redirecting to the group management page in the upper right corner based on the type are included. For the Fragment mode, only message-related content is included.
  • To redirect to the group management page, introduce the ZIMKitGroup module. Otherwise, an error is reported because the corresponding Activity cannot be found. If the group feature is available while you do not need to redirect to the group management page, modify the source code to hide the button in the upper right corner.

Directly redirect to Activity

MyZIMKitActivity.java

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import im.zego.zimkitcommon.enums.ZIMKitConversationType;
import im.zego.zimkitcommon.ZIMKitRouter;

public class MyZIMKitActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public void buttonClick() {
        String id = ; // userId or groupId or conversationId.
        ZIMKitConversationType type = ; // ZIMKitConversationType.ZIMKitConversationTypeGroup or ZIMKitConversationType.ZIMKitConversationTypePeer
        toMessageActivity(id,type);
    }
    
    private void toMessageActivity(String id,ZIMKitConversationType type){
        // You can redirect to the corresponding page through the Router at the kit layer.
        ZIMKitRouter.toMessageActivity(this, id, type);
    }
}
1
Copied!

Integrate the message page into your Activity as a Fragment

You can add the message component to the activity's view hierarchy either by defining the fragment in your activity's layout file or by defining a fragment container in your activity's layout file and then programmatically adding the fragment from within your activity.

Customize features

If the default message-relevant features and behaviors don't fully meet your needs, we allow you to flexibly customize those through the config we mentioned in this section.

API