# 20 messages limit for a chat

**URL:** <https://forum.social.plus/t/20-messages-limit-for-a-chat/1184>\
**Category:** iOS\
**Created:** [March 8, 2024, 1:59am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184 "2024-03-08T01:59:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisbay](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@chrisbay](https://forum.social.plus/u/chrisbay)\
**Post date:** [March 8, 2024, 1:59am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/1 "2024-03-08T01:59:48Z")

</div>

When querying messages for a chat, getMessages() returns only last 20 messages.

This bug exist since 5.33.8 version.

Amity SDK version: 6.28.0

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [March 8, 2024, 3:44am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/2 "2024-03-08T03:44:34Z")

</div>

Hello, to access messages beyond the 20th, pagination is required.

For more details, please refer to our documentation: [Query and Filter Messages - Amity Docs](https://docs.amity.co/amity-sdk/chat/messaging/query-and-filter-messages)

 ![Screenshot 2567-03-08 at 10.41.28](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/deb18eedba289121cb8ea4d69b1bb2fff3d9b875.png)

---

<div class="post-metadata">

**Author:** ![chrisbay](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@chrisbay](https://forum.social.plus/u/chrisbay)\
**Post date:** [March 11, 2024, 1:39am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/3 "2024-03-11T01:39:54Z")

</div>

Thank you for the update! There seems to be a bug with AmityCollection to be returning the previous message objects. Could you please verify on your end?

1. Enter chat (with 40 messages)
2. Load the next page
3. Exit chat (invalidate token, reset collection to nil…)
4. Enter same chat

Expected behaviour:

- Load chat with 20 messages

Actual result:

- Load previous 40 messages the very first time, then go back to loading first 20 messages…

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [March 11, 2024, 12:39pm UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/4 "2024-03-11T12:39:19Z")

</div>

@chrisbay Following your report, we have conducted a review and determined that this behavior aligns with the designed functionality of our product. The system caches data to avoid the need for reloading information.

---

<div class="post-metadata">

**Author:** ![chrisbay](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@chrisbay](https://forum.social.plus/u/chrisbay)\
**Post date:** [March 15, 2024, 12:08am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/5 "2024-03-15T00:08:27Z")

</div>

Thank you for looking into this! Caching data makes sense but what’s odd is that after you **invalidate** , you get cached data. Hence, one can observe the following crash:

```auto
Thread 1: "Invalid batch updates detected: the number of sections and/or rows returned by the data source before and/or after performing the batch updates are inconsistent with the updates.

```

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [March 15, 2024, 11:00am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/6 "2024-03-15T11:00:09Z")

</div>

Hello, just to clarify, are you experiencing a crash while attempting to observe the cache? Is that the issue you’re encountering?

---

<div class="post-metadata">

**Author:** ![YashK](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@YashK](https://forum.social.plus/u/YashK)\
**Post date:** [May 6, 2024, 8:12am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/7 "2024-05-06T08:12:24Z")

</div>

Hello, I go through the documentation you shared but I haven’t found anything related to pagination while using sdk to get messages using getMessages(). Can you please help me a little more or can provide a tutorial link about the same?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [May 7, 2024, 8:49am UTC](https://forum.social.plus/t/20-messages-limit-for-a-chat/1184/8 "2024-05-07T08:49:06Z")

</div>

@YashK Regarding your question, we recommend that you check this link: [https://docs.amity.co/amity-sdk/core-concepts/live-objects-collections/ios#pagination](https://docs.amity.co/amity-sdk/core-concepts/live-objects-collections/ios#pagination).
