Querying Messages
To query for a list of all messages in a channel:
This method will return a list of all messages in the specified channel. You can observe the list in order to update your view whenever you receive new messages.
with the
includingTags
andexcludingTags
parameters you can filter messages based on the tags set (or not set) in each messagewith the
parentId
parameter you can filter messages according to their relationship:if no
parentId
is passed, any message will matchif null
parentId
is passed, search for all messages without a parentif a non-null
parentId
is passed: query for all messages with the parentId as parent
with the
type
parameter you can filter messages according to their typeif no
type
is passed, any message will matchif an
AmityMessage.DataType
is passed, query for all messages with the specific typeAmityMessage.DataType.TEXT
for text messagesAmityMessage.DataType.IMAGE
for image messagesAmityMessage.DataType.FILE
for file messagesAmityMessage.DataType.AUDIO
for audio messagesAmityMessage.DataType.VIDEO
for video messagesAmityMessage.DataType.CUSTOM
for custom messages
Exclude delete messages in querying
A popular request was to have an isDeleted
boolean filter to avoid querying deleted messages to display in a chatroom. It is now available and can be used as:
The overall rule for the isDeleted
parameter is as following:
isDeleted = undefined
: both deleted and not deleted messages will be returnedisDeleted = true
: only deleted messages will be returnedisDeleted = false
: only non deleted messages will be returned
Threaded Messages
A message can be the root for a thread. To query the children of a message thread, you can add the parentId
parameter in a message query, along with the filterByParentId
flag.
Last updated