-
public abstract class BaseMessage
Base class for messages.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
BaseMessage.SendingStatus
Represents message sending status.
public interface
BaseMessage.GetThreadedMessagesHandler
GetThreadedMessages handler.See getThreadedMessagesByTimestamp.
public interface
BaseMessage.GetMessageHandler
GetMessage handler. This provides callback for getting a single message. getMessage
-
Field Summary
Fields Modifier and Type Field Description protected long
parentMessageId
protected String
mentionedMessageTemplate
private int
messageSurvivalSeconds
private String
parentMessageText
private ThreadInfo
threadInfo
private OGMetaData
ogMetaData
private boolean
isOperatorMessage
private AppleCriticalAlertOptions
appleCriticalAlertOptions
private boolean
isReplyToChannel
private BaseMessage
parentMessage
protected BaseMessage.SendingStatus
sendingStatus
-
Constructor Summary
Constructors Constructor Description BaseMessage(String channelUrl, long msgId, long createdAt)
-
Method Summary
Modifier and Type Method Description long
getParentMessageId()
Returns the parent message's ID if this is a child message. String
getMentionedMessageTemplate()
Returns the mentioned message template. void
setMentionedMessageTemplate(@Nullable() String mentionedMessageTemplate)
int
getMessageSurvivalSeconds()
Returns the message's survival seconds. String
getParentMessageText()
Returns the message text of the UserMessage or the file name of the FileMessage. ThreadInfo
getThreadInfo()
The thread info that belongs to this message object. OGMetaData
getOgMetaData()
Retrieve OGMetaData of the message.Might be null if1. boolean
isOperatorMessage()
Returns boolean value that can be used to test if the message was sent from an operator. void
setIsOperatorMessage(boolean isOperatorMessage)
AppleCriticalAlertOptions
getAppleCriticalAlertOptions()
gets apple critical alert options of this instance. void
setAppleCriticalAlertOptions(@NonNull() AppleCriticalAlertOptions appleCriticalAlertOptions)
sets apple critical alert options for this instance. boolean
isReplyToChannel()
Determines whether the current message is a replied message and also a message was replied to the channel. void
setIsReplyToChannel(boolean isReplyToChannel)
BaseMessage
getParentMessage()
Returns the parent message of this message. BaseMessage.SendingStatus
getSendingStatus()
Returns message sending status. void
setSendingStatus(BaseMessage.SendingStatus sendingStatus)
static void
getMessage(MessageRetrievalParams params, BaseMessage.GetMessageHandler handler)
Retrieves a BaseMessage
object with a specified message ID.abstract String
getRequestId()
Returns a message request ID. String
getMessage()
Returns message text. Sender
getSender()
Returns sender of message. boolean
isResendable()
Returns whether resend is possible. static boolean
belongsTo(BaseMessage message, String userId)
Checks whether the sender's userId of the BaseMessage
equals the given userId.static boolean
belongsTo(BaseMessage message, User user)
Checks whether the sender's userId of the BaseMessage
equals the given user's id.static BaseMessage
buildFromSerializedData(Array<byte> data)
Builds UserMessage
,FileMessage
orAdminMessage
instancefrom serialized data generated by serialize.static BaseMessage
buildFromSerializedData(Array<byte> data, BaseMessage.SendingStatus desiredState)
Builds UserMessage
,FileMessage
orAdminMessage
instance from serialized data generated by serialize.Array<byte>
serialize()
Serializes the UserMessage
,FileMessage
orAdminMessage
instance.This byte array can be stored in the database in your application.long
getMessageId()
Returns message ID. long
getCreatedAt()
Returns message creation time. long
getUpdatedAt()
Returns message updated time. BaseMessageParams.MentionType
getMentionType()
Returns mention type. List<User>
getMentionedUsers()
Returns mentioned users. String
getChannelUrl()
Returns the channel URL of this message belongs to. boolean
isOpenChannel()
Checks if this message is from OpenChannel
.boolean
isGroupChannel()
Checks if this message is from GroupChannel
.String
getData()
Returns message custom data. String
getCustomType()
Returns the custom type of message. List<Reaction>
getReactions()
Returns reactions. Map<String, List<String>>
getAllMetaArray()
Returns all meta array key-value map. List<MessageMetaArray>
getAllMetaArrays()
Returns all MessageMetaArrays. Map<String, List<String>>
getMetaArray(Collection<String> metaArrayKeys)
Returns the meta array key-value map whose keys match metaArrayKeys. List<MessageMetaArray>
getMetaArrays(Collection<String> metaArrayKeys)
Returns MessageMetaArray list which is filtered by given metaArrayKeys. int
getErrorCode()
Returns error code. boolean
applyReactionEvent(ReactionEvent reactionEvent)
Applies ReactionEvent
to message.boolean
applyThreadInfoUpdateEvent(ThreadInfoUpdateEvent threadInfoUpdateEvent)
Applies ThreadInfoUpdateEvent to a message. void
getThreadedMessagesByTimestamp(long ts, ThreadMessageListParams params, BaseMessage.GetThreadedMessagesHandler handler)
Retrieves the threaded replies of the current message depending on the timestamp.If the current message doesn’t have replies, the result is an empty list. boolean
isSilent()
Checks whether the message is silent or not. boolean
applyParentMessage(@NonNull() BaseMessage parentMessage)
When parent message is updated, you can update the child message's parent message through this methodIf you use MessageCollection, messages in the collection are automatically updated, so don't need to call it boolean
equals(Object o)
int
hashCode()
String
toString()
static BaseMessage
clone(BaseMessage msg)
Clones and returns a new instance of given BaseMessage -
-
Constructor Detail
-
BaseMessage
BaseMessage(String channelUrl, long msgId, long createdAt)
-
-
Method Detail
-
getParentMessageId
long getParentMessageId()
Returns the parent message's ID if this is a child message.
-
getMentionedMessageTemplate
@Nullable() String getMentionedMessageTemplate()
Returns the mentioned message template.
-
setMentionedMessageTemplate
void setMentionedMessageTemplate(@Nullable() String mentionedMessageTemplate)
-
getMessageSurvivalSeconds
int getMessageSurvivalSeconds()
Returns the message's survival seconds.
-
getParentMessageText
@Deprecated() String getParentMessageText()
Returns the message text of the UserMessage or the file name of the FileMessage.
-
getThreadInfo
ThreadInfo getThreadInfo()
The thread info that belongs to this message object.
-
getOgMetaData
OGMetaData getOgMetaData()
Retrieve OGMetaData of the message.Might be null if1. Application does not support OG-TAG. (all new applications support OG-TAG by default)2. The message does not contain a valid url.3. The server did not fetch the OG-Tag yet. (would be updated through onMessageUpdated callback.
-
isOperatorMessage
boolean isOperatorMessage()
Returns boolean value that can be used to test if the message was sent from an operator.
This value is true if the sender of this message was an operator at the moment this messagewas sent.
Note that getRole returns the role of the sender at the current moment (whenthe server response was sent). So if the sender's operator status changed after sending amessage, the value returned by this method and the result of
might differ.Sender#getRole() == Member.Role.OPERATOR
-
setIsOperatorMessage
void setIsOperatorMessage(boolean isOperatorMessage)
-
getAppleCriticalAlertOptions
@Nullable() AppleCriticalAlertOptions getAppleCriticalAlertOptions()
gets apple critical alert options of this instance.
-
setAppleCriticalAlertOptions
void setAppleCriticalAlertOptions(@NonNull() AppleCriticalAlertOptions appleCriticalAlertOptions)
sets apple critical alert options for this instance.
- Parameters:
appleCriticalAlertOptions
- an instance of AppleCriticalAlertOptions
-
isReplyToChannel
boolean isReplyToChannel()
Determines whether the current message is a replied message and also a message was replied to the channel.
-
setIsReplyToChannel
void setIsReplyToChannel(boolean isReplyToChannel)
-
getParentMessage
@Nullable() BaseMessage getParentMessage()
Returns the parent message of this message. Only
NonNull
if this message is a threaded message.It does not contain all properties of the parent message.Only contains: - getMessage.- getSender. (null if the parent message is an AdminMessage). - getCreatedAt. - file information if it's a FileMessage.- getName.- getType.- getUrl.This is only for accessing parent message's information (READ ONLY) and should not to be used to modify the parent message.
-
getSendingStatus
BaseMessage.SendingStatus getSendingStatus()
Returns message sending status.
-
setSendingStatus
void setSendingStatus(BaseMessage.SendingStatus sendingStatus)
-
getMessage
static void getMessage(MessageRetrievalParams params, BaseMessage.GetMessageHandler handler)
Retrieves a
BaseMessage
object with a specified message ID.- Parameters:
params
- MessageRetrievalParams.handler
- Callback handler.
-
getRequestId
abstract String getRequestId()
Returns a message request ID.
-
getMessage
String getMessage()
Returns message text.
-
getSender
Sender getSender()
Returns sender of message. If useMemberAsMessageSender is set
true
,the sender information such as nickname and profile url is returned as the same with the channel member's. Otherwise,the sender information will be returned as the value of the message creation time.
-
isResendable
boolean isResendable()
Returns whether resend is possible.
-
belongsTo
static boolean belongsTo(BaseMessage message, String userId)
Checks whether the sender's userId of the
BaseMessage
equals the given userId.- Parameters:
message
-BaseMessage
to check userId.userId
- UserId to check.
-
belongsTo
static boolean belongsTo(BaseMessage message, User user)
Checks whether the sender's userId of the
BaseMessage
equals the given user's id.- Parameters:
message
-BaseMessage
to check user.user
- User to check.
-
buildFromSerializedData
static BaseMessage buildFromSerializedData(Array<byte> data)
Builds
UserMessage
,FileMessage
orAdminMessage
instancefrom serialized data generated by serialize.- Parameters:
data
- SerializedUserMessage
,FileMessage
orAdminMessage
data.
-
buildFromSerializedData
static BaseMessage buildFromSerializedData(Array<byte> data, BaseMessage.SendingStatus desiredState)
Builds
UserMessage
,FileMessage
orAdminMessage
instance from serialized data generated by serialize.Unlike buildFromSerializedData, this method takes an extra argument'desiredState'. This argument will override the returned BaseMessage's SendingStatus.Under normal development scenarios, most application developers won't need to use thismethod. Changing a message's sending state may corrupt Sendbird SDK's internal states andmay lead to undesired results.The rebuilt BaseMessage instance will have an error code of ERR_PENDING if the instance's SendingStatus changed from PENDING to FAILED.- Parameters:
data
- SerializedUserMessage
,FileMessage
orAdminMessage
data.
-
serialize
Array<byte> serialize()
Serializes the
UserMessage
,FileMessage
orAdminMessage
instance.This byte array can be stored in the database in your application.The instance can be restored by buildFromSerializedData.
-
getMessageId
long getMessageId()
Returns message ID.
-
getCreatedAt
long getCreatedAt()
Returns message creation time.
-
getUpdatedAt
long getUpdatedAt()
Returns message updated time.
-
getMentionType
BaseMessageParams.MentionType getMentionType()
Returns mention type. Refer to BaseMessageParams.MentionType.
-
getMentionedUsers
List<User> getMentionedUsers()
Returns mentioned users.
-
getChannelUrl
String getChannelUrl()
Returns the channel URL of this message belongs to.
-
isOpenChannel
boolean isOpenChannel()
Checks if this message is from
OpenChannel
.
-
isGroupChannel
boolean isGroupChannel()
Checks if this message is from
GroupChannel
.
-
getCustomType
String getCustomType()
Returns the custom type of message.
-
getReactions
List<Reaction> getReactions()
Returns reactions. (Immutable List)
-
getAllMetaArray
@Deprecated() Map<String, List<String>> getAllMetaArray()
Returns all meta array key-value map.
-
getAllMetaArrays
List<MessageMetaArray> getAllMetaArrays()
Returns all MessageMetaArrays.
-
getMetaArray
@Deprecated() Map<String, List<String>> getMetaArray(Collection<String> metaArrayKeys)
Returns the meta array key-value map whose keys match metaArrayKeys.
- Parameters:
metaArrayKeys
- Meta array keys.
-
getMetaArrays
List<MessageMetaArray> getMetaArrays(Collection<String> metaArrayKeys)
Returns MessageMetaArray list which is filtered by given metaArrayKeys.
- Parameters:
metaArrayKeys
- Meta array Keys.
-
getErrorCode
int getErrorCode()
Returns error code.
-
applyReactionEvent
boolean applyReactionEvent(ReactionEvent reactionEvent)
Applies
ReactionEvent
to message.- Parameters:
reactionEvent
- ReactionEvent reaction event from onReactionUpdated().
-
applyThreadInfoUpdateEvent
boolean applyThreadInfoUpdateEvent(ThreadInfoUpdateEvent threadInfoUpdateEvent)
Applies ThreadInfoUpdateEvent to a message.
- Parameters:
threadInfoUpdateEvent
- ThreadInfoUpdateEvent from onThreadInfoUpdated.
-
getThreadedMessagesByTimestamp
void getThreadedMessagesByTimestamp(long ts, ThreadMessageListParams params, BaseMessage.GetThreadedMessagesHandler handler)
Retrieves the threaded replies of the current message depending on the timestamp.If the current message doesn’t have replies, the result is an empty list.The result is passed to
handler
aslist
.- Parameters:
ts
- Specifies the timestamp to be the reference point of the retrieval, in Unix milliseconds format.params
- Params for getting thread message list.handler
- Callback handler.
-
isSilent
boolean isSilent()
Checks whether the message is silent or not.
-
applyParentMessage
boolean applyParentMessage(@NonNull() BaseMessage parentMessage)
When parent message is updated, you can update the child message's parent message through this methodIf you use MessageCollection, messages in the collection are automatically updated, so don't need to call it
- Parameters:
parentMessage
- updated parent message.
-
hashCode
int hashCode()
-
clone
static BaseMessage clone(BaseMessage msg)
Clones and returns a new instance of given BaseMessage
- Parameters:
msg
-BaseMessage
object to clone.
-
-
-
-