Class Message

  • All Implemented Interfaces:

    
    public class Message
    
                        

    The message object that contains and stores the message information received by the client, corresponding to the message in the chat UI.

    Author:

    rongcloud

    • Constructor Detail

      • Message

        Message()
        Default constructor.
      • Message

        Message(Parcel in)
    • Method Detail

      • getConversationType

         ConversationType getConversationType()

        Retrieves the conversation type.

        Returns:

        The conversation type.

      • setConversationType

         void setConversationType(ConversationType conversationType)

        Sets the conversation type.

        Parameters:
        conversationType - Specifies the conversation type.
      • getTargetId

         String getTargetId()

        Retrieves the target ID.

        Depending on the conversationType, this could be a user ID, discussion group ID, group ID, or chatroom ID.

        Returns:

        The value of the target ID.

      • setTargetId

         void setTargetId(String targetId)

        Sets the target ID.

        Depending on the conversationType, this could be a user ID, discussion group ID, group ID, or chatroom ID.

        Parameters:
        targetId - The value of the target ID.
      • getChannelId

         String getChannelId()

        Get Channel ID

        Returns:

        Channel ID

      • setChannelId

         void setChannelId(String channelId)

        Sets the channel ID with a maximum length of 20 characters.

        Parameters:
        channelId - The channel ID
      • getMessageId

         int getMessageId()

        Retrieves the unique value (database index unique value) of the locally stored message.

        Returns:

        The unique value (database index unique value) of the locally stored message.

      • setMessageId

         void setMessageId(int messageId)

        Sets the unique value for the locally stored message (database index unique value).

        Parameters:
        messageId - The unique value for the locally stored message (database index unique value).
      • getSenderUserId

         String getSenderUserId()

        Retrieves the user ID of the message sender.

        Returns:

        The user ID of the message sender.

      • setSenderUserId

         void setSenderUserId(String senderUserId)

        Sets the user ID of the message sender.

        Parameters:
        senderUserId - The user ID of the message sender.
      • setReceivedStatus

         void setReceivedStatus(Message.ReceivedStatus receivedStatus)

        Sets the received status of the message.

        Parameters:
        receivedStatus - Indicates the received status of the message.
      • setSentStatus

         void setSentStatus(Message.SentStatus sentStatus)

        Sets the sending status of the message.

        Parameters:
        sentStatus - The sending status of the message.
      • getReceivedTime

         long getReceivedTime()

        Gets the message received time (Unix timestamp in milliseconds).

        The received time is the local time of the client when the message arrives at the receiving client.

        Returns:

        The message received time (Unix timestamp in milliseconds).

      • setReceivedTime

         void setReceivedTime(long receivedTime)

        Sets the message received time (Unix timestamp in milliseconds).

        The received time is the local time of the client when the message arrives at the receiving client.

        Parameters:
        receivedTime - The message received time (Unix timestamp in milliseconds).
      • getSentTime

         long getSentTime()

        Get the message sending time (Unix timestamp, in milliseconds).

        The sending time is the server time when the message arrives at the server from the sending client.

        Returns:

        The message sending time (Unix timestamp, in milliseconds).

      • setSentTime

         void setSentTime(long sentTime)

        Sets the message sending time (Unix timestamp in milliseconds).

        The sending time is the server time when the message arrives at the server from the sending client.

        Parameters:
        sentTime - The message sending time (Unix timestamp in milliseconds).
      • getObjectName

         String getObjectName()

        Gets the name of the message object.

        The name of the message object corresponds to the value specified in the annotation.

        Returns:

        The name of the message object.

      • setObjectName

         void setObjectName(String objectName)

        Sets the name of the message object.

        The message object name corresponds to the value specified in the annotation.

        Parameters:
        objectName - The name of the message object.
      • getContent

         MessageContent getContent()

        Retrieves the message content.

        Returns:

        The message content.

      • setContent

         void setContent(MessageContent content)

        Sets the message content.

        Parameters:
        content - The content of the message.
      • getExtra

         String getExtra()

        Retrieves the additional information of the message.

        Returns:

        The additional information of the message.

      • setExtra

         void setExtra(String extra)

        Sets the extra information of the message.

        Parameters:
        extra - The extra information of the message.
      • getReadReceiptInfo

         ReadReceiptInfo getReadReceiptInfo()

        Get the read receipt status

        Returns:

        The read receipt status

      • setReadReceiptInfo

         void setReadReceiptInfo(ReadReceiptInfo readReceiptInfo)

        Sets the read receipt status

        Parameters:
        readReceiptInfo - The read receipt status
      • getReadReceiptInfoV4

         ReadReceiptInfoV4 getReadReceiptInfoV4()

        Retrieves the Read Receipt V4 information.

        Returns:

        The Read Receipt V4 information

      • setReadReceiptInfoV4

         void setReadReceiptInfoV4(ReadReceiptInfoV4 readReceiptInfo)

        Sets the read receipt V4 information

        Parameters:
        readReceiptInfo - The read receipt V4 information
      • getMessageConfig

         MessageConfig getMessageConfig()

        Get Message Configuration

        Returns:

        MessageConfig Specifies the message configuration

      • setMessageConfig

         void setMessageConfig(MessageConfig messageConfig)

        Set message configuration

        Parameters:
        messageConfig - Message configuration
      • getMessagePushConfig

         MessagePushConfig getMessagePushConfig()

        Get Push Notification Configuration

        Returns:

        MessagePushConfig Push notification configuration

      • setMessagePushConfig

         void setMessagePushConfig(MessagePushConfig messagePushConfig)

        Set push notification configuration

        Parameters:
        messagePushConfig - Push notification configuration
      • isOffline

         boolean isOffline()

        Indicates whether the message is an offline message.

        This field is invalid for messages retrieved from the database.

        Only valid in the message received callback method.

        YES if the message is an offline message. NO in all other cases.
      • setOffline

         void setOffline(boolean offLine)

        Sets whether the message is an offline message.

        Parameters:
        offLine - Indicates whether the message is an offline message.
      • getExpansion

         Map<String, String> getExpansion()

        List of message extension information

        Returns:

        List of message extension information

      • getDirectedUserIds

         List<String> getDirectedUserIds()

        Get the list of targeted users

        Returns empty for one-to-one chat conversation type

        Returns:

        The list of targeted users

        Since:

        5.8.0

      • setDirectedUserIds

         void setDirectedUserIds(List<String> directedUserIds)

        Set the list of targeted users

        Parameters:
        directedUserIds - List of targeted users
        Since:

        5.8.0

      • obtain

         static Message obtain(String targetId, ConversationType type, MessageContent content)

        Constructor.

        Parameters:
        targetId - Conversation ID
        type - Conversation type
        content - Message content
        Returns:

        Message object

      • obtain

         static Message obtain(ConversationIdentifier conversationIdentifier, MessageContent content)

        Constructor.

        Parameters:
        conversationIdentifier - Conversation identifier
        content - Message content
        Returns:

        Message object

      • obtain

         static Message obtain(String targetId, ConversationType type, String channelId, MessageContent content)

        Constructor.

        Parameters:
        targetId - Conversation ID
        type - Conversation type
        channelId - Conversation channel ID
        content - Message content
        Returns:

        Message object

      • getUId

         String getUId()

        Get the unique ID of the server message (globally unique under the same AppKey).

        Returns:

        uid The unique ID of the server message (globally unique under the same AppKey).

      • setUId

         void setUId(String UId)

        Sets the unique ID for the server message (globally unique within the same AppKey).

        Parameters:
        UId - The unique ID for the server message (globally unique within the same AppKey)
      • getGroupReadReceiptInfoV2

         GroupReadReceiptInfoV2 getGroupReadReceiptInfoV2()

        Get Read Receipt V2 Information

        Returns:

        Read Receipt V2 Information

      • setGroupReadReceiptInfoV2

         void setGroupReadReceiptInfoV2(GroupReadReceiptInfoV2 v2)

        Sets the read receipt V2 information.

        Parameters:
        v2 - The read receipt V2 information
      • isCanIncludeExpansion

         boolean isCanIncludeExpansion()

        Indicates whether the message can include extended information.

        This property is determined when the message is sent and cannot be modified afterward. Extended information is only supported in one-to-one and group chats; other conversation types cannot set extended information.

        Returns:

        Indicates whether the message can include extended information.

      • setExpansion

         void setExpansion(HashMap<String, String> expansion)

        Set the message extension information list

        Extension information is only supported for one-to-one chat and group chat. Other conversation types cannot set extension information.

        By default, the message extension dictionary key length cannot exceed 32, and the value length cannot exceed 4096. The maximum number of extensions that can be set at once is 20, and the total number of extensions for a message cannot exceed 300.

        Parameters:
        expansion - The message extension information list
      • isHasChanged

         boolean isHasChanged()

        Indicates whether the message has been modified.

        Returns:

        Specifies whether the message has been modified.

      • equals

         boolean equals(Object o)
      • setCanIncludeExpansion

         void setCanIncludeExpansion(boolean canIncludeExpansion)

        Sets whether to include extended information.

        Parameters:
        canIncludeExpansion - Indicates whether to include extended information.
      • setHasChanged

         void setHasChanged(boolean hasChanged)

        Sets whether the message has been modified.

        Parameters:
        hasChanged - Indicates whether the message has been modified.