Skip to main content
Key methods: set(uid:), set(guid:), set(limit:), set(categories:), set(types:), setTags(_:), set(unread:), setParentMessageId(parentMessageId:), set(messageID:), set(timeStamp:), hideReplies(hide:), hideDeletedMessages(hide:)
The MessagesRequest class fetches messages based on various parameters. It uses the Builder design pattern via MessagesRequestBuilder.
MethodDescription
fetchNext()Returns messages after the specified parameters
fetchPrevious()Returns messages before the specified parameters
Messages are paginated with a maximum of 100 per request. Call fetchPrevious()/fetchNext() repeatedly on the same object to get subsequent pages. Both methods return an array of BaseMessage objects. Each message may be a TextMessage, MediaMessage, CustomMessage, Action, or Call. Use type checking to determine the specific type.

Number of messages fetched

Set the number of messages to fetch per request using setLimit(). Maximum is 100.

Messages for a user conversation

Use set(uid:) to fetch messages between the logged-in user and a specific user.

Messages for a group conversation

Use set(guid:) to fetch messages from a group.
If neither set(uid:) nor set(guid:) is used, all messages for the logged-in user will be fetched across all conversations.

Messages before/after a message

Use set(messageID:) to fetch messages before or after a specific message ID. Use fetchNext() to get messages after, or fetchPrevious() to get messages before.

Messages before/after a given time

Use set(timeStamp:) with a Unix timestamp to fetch messages before or after a specific time.

Unread messages

Use set(unread:) to fetch only unread messages.

Messages for multiple categories

Use set(categories:) with an array of category names. See Message structure and hierarchy for available categories.

Messages for multiple types

Use set(types:) with an array of type names.

Messages by tags

Use setTags() with an array of tag names to fetch only messages with those tags.

Next Steps

Receive Messages

Listen for incoming messages in real-time

Threaded Messages

Organize conversations with message threads

Message Structure

Understand message categories and types