Is there any way to enable chat history programmatically in android

can we enable history of any group channel by code in android (java)


// If problem, please fill out the below. If question, please delete.
[UIKit Version = 3.4.5]
// What version of the SDK are you using?
min 23
max 33

Hello @Mayank_Ingle ,

Yes, you can enable the history of a group channel by code in Android (Java). You can use the setChannelHiddenState() method to enable or disable the history of a group channel. Here’s an example of how you can enable the history of a group channel:

GroupChannelParams params = new GroupChannelParams()
.setChannelUrl(“CHANNEL_URL”)
.setHiddenState(false); // Set hidden state to false to enable history

GroupChannel.createChannel(params, new GroupChannel.GroupChannelCreateHandler() {
@Override
public void onResult(GroupChannel groupChannel, SendBirdException e) {
if (e != null) {
// Handle error
} else {
// History enabled successfully
}
}
});

Note: Make sure to replace “CHANNEL_URL” with the actual URL of the group channel you want to enable the history for.

Let me know if this helps.

am not able to implement setHiddenState in my code as is says Cannot resolve symbol ‘setHiddenState’

am using SendbirdUIkit ;

dependency integradted is ‘com.sendbird.sdk:uikit:3.6.0’

my code :-1:

GroupChannelCreateParams groupChannelCreateParams = new GroupChannelCreateParams();
groupChannelCreateParams.setName(partyTitle);
groupChannelCreateParams.setCoverUrl(creater.getProfilePic());
groupChannelCreateParams.setChannelUrl(groupUrl);
groupChannelCreateParams.setOperatorUserIds(operators);
groupChannelCreateParams.setDistinct(false);
groupChannelCreateParams.setPublic(true);

Hello Mayank,

I will checking more on it. In meantime can you let me know if there is any reason you don’t want to enable it on Sendbird Dashboard by going to → Settings > Chat > Channels > Group channels > Chat history ?

well i had done this process too but when a new user joins a group he is not able to view previous chat log .

Hello @Mayank_Ingle,

In this case, you will need to check if there is a channel custom_type setting “display_past_message” and it’s set to false.
This needs to be set as true.

Let me know if this helps.