Getting first message of channel

[Problem/Question]
I am trying to get the first message of a channel regardless of a user’s joined status in that channel.
However, messages before the user joined do not come back. I have tried both api and message collection. I have also tried toggling on/off the chat history option in the sendbird dashboard that allows users to see messages from before they joined.

Specifically, and regardless of any chat history problems, I just need to get the first message in a channel. If somebody has a quicker way to do this, please let me know and that will solve my problem.

Additional info -
React Native .70.
I am filtering to get MessageTypeFilter.USER messages.
All of these groups are super groups.

Using the SDK -
I cannot get any messages before the user joined, regardless of starting point, limit, nextResultLimit, prevResultLimit, and channel.

Using the API -
If I pass in Date.now() as starting point, I can get messages before the user joined.
If I pass in any other time, I cannot. This is regardless of any other parameters passed in.


// If problem, please fill out the below. If question, please delete.
[SDK Version]
4.12.3

[Reproduction Steps]
Join a channel that already has messages in it.
Create a message collection and filter by MessageTypeFilter.USER.
See if messages come back before you joined.

Use the Api instead of a message collection to get messages, filtered by MessageTypeFilter.USER.
Pass in Date.now().
Do it again, pass in any other time. Compare the result.

[Frequency]
Every channel of the same custom type, every time.
Other channel custom types are experiencing similar, but not exactly the same discrepancies with joining and being able to fetch chat history.

[Current impact]
It is breaking a feature of my app’s chat capabilities.

Hello @allisonadam81,

Welcome to the Sendbird Community.

Messages that exist prior to a user joining the channel are generally not shown. That being said, you can enable this in the Sendbird Dashboard ,as you already know, by going to Settings > Chat > Channels and enabling Chat History. Please note that this is not a retroactive change and only impacts users that join channels after the change has been made.

If the channel has a lot of older messages, then you will need to paginate through the messages in the channel in order to get back to the very first message, unless you know the specific message_id. If you’re always trying to fetch the first message in the channel to display it in a specific manner, you might consider adding the message_id of the first message to the channel’s data object. This would allow you to query for that specific message on the front end without having to paginate through all of the messages.

Regarding API vs SDK behavior, its very important to realize that the SDK and the API work under different contexts. The SDK only sees data in the context of the user who’s logged in. So what they see, or what is returned will depend on the user. The Platform API however does not have a user context (in terms of data access) and thus can see much more information.