Options
All
  • Public
  • Public/Protected
  • All
Menu

export class type

Hierarchy

  • ChatMessage

Index

Constructors

  • new ChatMessage(params: { attributes?: any; body: any; chatType?: number; conversationId?: string; deliverOnlineOnly?: boolean; direction?: string; from?: string; groupAckCount?: number; hasDeliverAck?: boolean; hasRead?: boolean; hasReadAck?: boolean; isChatThread?: boolean; isOnline?: boolean; localMsgId?: string; localTime?: number; msgId?: string; needGroupAck?: boolean; receiverList?: string[]; serverTime?: number; status?: number; to?: string }): ChatMessage
  • Constructs a message.

    Parameters

    • params: { attributes?: any; body: any; chatType?: number; conversationId?: string; deliverOnlineOnly?: boolean; direction?: string; from?: string; groupAckCount?: number; hasDeliverAck?: boolean; hasRead?: boolean; hasReadAck?: boolean; isChatThread?: boolean; isOnline?: boolean; localMsgId?: string; localTime?: number; msgId?: string; needGroupAck?: boolean; receiverList?: string[]; serverTime?: number; status?: number; to?: string }
      • Optional attributes?: any
      • body: any
      • Optional chatType?: number
      • Optional conversationId?: string
      • Optional deliverOnlineOnly?: boolean
      • Optional direction?: string
      • Optional from?: string
      • Optional groupAckCount?: number
      • Optional hasDeliverAck?: boolean
      • Optional hasRead?: boolean
      • Optional hasReadAck?: boolean
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean
      • Optional localMsgId?: string
      • Optional localTime?: number
      • Optional msgId?: string
      • Optional needGroupAck?: boolean
      • Optional receiverList?: string[]
      • Optional serverTime?: number
      • Optional status?: number
      • Optional to?: string

    Returns ChatMessage

Properties

attributes: Object = {}

The extension attribute of the message.

The message body. See ChatMessageBody.

The conversation type. See {@link ChatType}.

conversationId: string = ''

The conversation ID.

deliverOnlineOnly: boolean

Whether the message is delivered only when the recipient(s) is/are online:

  • true:The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
  • (Default) false:The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.

The message direction. See ChatMessageDirection.

from: string = ''

The user ID of the message sender.

groupAckCount: number = 0

The number of members that have read the group message.

hasDeliverAck: boolean = false

Whether the delivery receipt is required, which is to check whether the message is delivered successfully.

  • true: Yes.
  • (Default) false: No.
hasRead: boolean = false

Whether the message is read.

  • true: Yes.
  • (Default) false: No.
hasReadAck: boolean = false

Whether the message read receipt is required.

  • true: Yes.
  • (Default) false: No.
isChatThread: boolean

Whether it is a message in a message thread.

  • true: Yes. In this case, you need to set the user ID of the message recipient to the message thread ID. See to.
  • false: No.

Note

This parameter is valid only for group chat.

isOnline: boolean

Whether it is a online message.

  • true: Yes. In this case, if the application is running in the background, a notification window may pop up.
  • false: No.
localMsgId: string = ''

The local message ID.

localTime: number = ...

The Unix timestamp when the message is created locally. The unit is millisecond.

msgId: string = ...

The message ID generated on the server.

needGroupAck: boolean = false

Whether read receipts are required for group messages.

  • true: Yes.
  • (Default) false: No.

The delivery priorities of chat room messages. Note Only for chat rooms.

receiverList?: string[]

The recipient list of a targeted message.

The default value is undefined, indicating that the message is sent to all members in the group or chat room.

This property is used only for messages in groups and chat rooms.

serverTime: number = ...

The Unix timestamp when the server receives the message. The unit is millisecond.

status: ChatMessageStatus = ChatMessageStatus.CREATE

The message sending status. See ChatMessageStatus.

to: string = ''

The user ID of the message recipient:

  • For the one-to-one chat, it is the user ID of the message recipient;
  • For the group chat, it is the group ID;
  • For the chat room chat, it is the chat room ID;
  • For a message thread, it is the ID of the message thread.
TAG: string = 'ChatMessage'

Accessors

  • get groupReadCount(): Promise<number>
  • Gets the count of read receipts of a group message.

    Returns Promise<number>

Methods

  • createCmdMessage(targetId: string, action: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean }): ChatMessage
  • Creates a command message for sending.

    params

    opt The extension parameters of the message.

    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.
    • deliverOnlineOnly: Whether this command message is delivered only to the online users.
      • (Default) true: Yes.
      • false: No. The command message is delivered to users, regardless of their online or offline status.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • action: string

      The command action.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean }
      • Optional deliverOnlineOnly?: boolean
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean

    Returns ChatMessage

    The message instance.

  • createCombineMessage(targetId: string, messageIdList: string[], chatType?: ChatMessageChatType, opt?: { compatibleText?: string; deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean; summary?: string; title?: string }): ChatMessage
  • Creates a combined message for sending.

    params

    opt The extension parameters of the message.

    • title: The title of the combined message.
    • summary: The summary of the combined message.
    • compatibleText: The compatible text of the combined message. This field is used for compatibility with SDK versions that do not support combined messages.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false:No.
    • isOnline: Whether it is a online message.
      • true: Yes.
      • false:No.
    • deliverOnlineOnly: Whether the message is delivered only when the recipient(s) is/are online:
      • true: - true:The message is delivered only when the recipient(s) is/are online. If the recipient is offline, the message is discarded.
      • (Default) false:The message is delivered when the recipient(s) is/are online. If the recipient(s) is/are offline, the message will not be delivered to them until they get online.

    Parameters

    • targetId: string

      The message recipient. The field setting is determined by the conversation type:

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • messageIdList: string[]

      A collection of message IDs. The list cannot be empty. It can contain a maximum of 300 message IDs.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { compatibleText?: string; deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean; summary?: string; title?: string }
      • Optional compatibleText?: string
      • Optional deliverOnlineOnly?: boolean
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean
      • Optional summary?: string
      • Optional title?: string

    Returns ChatMessage

    The message instance.

  • createCustomMessage(targetId: string, event: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean; params: Record<string, string> }): ChatMessage
  • Creates a custom message for sending.

    params

    opt The extension parameters of the message.

    • params: The dictionary of custom parameters.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • event: string

      The custom event.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean; params: Record<string, string> }
      • Optional deliverOnlineOnly?: boolean
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean
      • params: Record<string, string>

    Returns ChatMessage

    The message instance.

  • createFileMessage(targetId: string, filePath: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; displayName: string; fileSize?: number; isChatThread?: boolean; isOnline?: boolean }): ChatMessage
  • Creates a message with a file attachment for sending.

    params

    opt The extension parameters of the message.

    • displayName: The file name.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.
    • isOnline: Whether it is a online message.
    • deliverOnlineOnly: Whether the message is delivered only when the recipient(s) is/are online.
    • fileSize: The file size.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • filePath: string

      The file path.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; displayName: string; fileSize?: number; isChatThread?: boolean; isOnline?: boolean }
      • Optional deliverOnlineOnly?: boolean
      • displayName: string
      • Optional fileSize?: number
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean

    Returns ChatMessage

    The message instance.

  • createImageMessage(targetId: string, filePath: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; displayName: string; fileSize?: number; height: number; isChatThread?: boolean; isOnline?: boolean; sendOriginalImage?: boolean; thumbnailLocalPath?: string; width: number }): ChatMessage
  • Creates an image message for sending.

    params

    opt The extension parameters of the message.

    • displayName: The image name.
    • thumbnailLocalPath: The image thumbnail path.
    • sendOriginalImage: Whether to send the original image.
      • true: Yes.
      • (Default) false: If the image is equal to or greater than 100 KB, the SDK will compress it before sending the compressed image.
    • width: The image width in pixels.
    • height: The image height in pixels.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.
    • isOnline: Whether it is a online message.
    • deliverOnlineOnly: Whether the message is delivered only when the recipient(s) is/are online.
    • fileSize: The file size.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • filePath: string

      The image path.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; displayName: string; fileSize?: number; height: number; isChatThread?: boolean; isOnline?: boolean; sendOriginalImage?: boolean; thumbnailLocalPath?: string; width: number }
      • Optional deliverOnlineOnly?: boolean
      • displayName: string
      • Optional fileSize?: number
      • height: number
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean
      • Optional sendOriginalImage?: boolean
      • Optional thumbnailLocalPath?: string
      • width: number

    Returns ChatMessage

    The message instance.

  • createLocationMessage(targetId: string, latitude: string, longitude: string, chatType?: ChatMessageChatType, opt?: { address: string; deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean }): ChatMessage
  • Creates a location message for sending.

    params

    opt The extension parameters of the message.

    • address: The location details.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • latitude: string

      The latitude.

    • longitude: string

      The longitude.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { address: string; deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean }
      • address: string
      • Optional deliverOnlineOnly?: boolean
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean

    Returns ChatMessage

    The message instance.

  • Creates a received message instance.

    Parameters

    • params: any

      The received message.

    Returns ChatMessage

    The message object.

  • createTextMessage(targetId: string, content: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean; targetLanguageCodes?: string[] }): ChatMessage
  • Creates a text message for sending.

    params

    opt The extension parameters of the message.

    • targetLanguageCodes: The language code. See ChatTextMessageBody.targetLanguageCodes.
    • isChatThread: Whether this message is a threaded message.
    • true: Yes.
    • (Default) false: No.
    • isOnline: Whether it is a online message.
    • deliverOnlineOnly: Whether the message is delivered only when the recipient(s) is/are online.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • content: string

      The text content.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; isChatThread?: boolean; isOnline?: boolean; targetLanguageCodes?: string[] }
      • Optional deliverOnlineOnly?: boolean
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean
      • Optional targetLanguageCodes?: string[]

    Returns ChatMessage

    The message instance.

  • createVideoMessage(targetId: string, filePath: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; displayName: string; duration: number; fileSize?: number; height: number; isChatThread?: boolean; isOnline?: boolean; thumbnailLocalPath: string; width: number }): ChatMessage
  • Creates a video message for sending.

    params

    opt The extension parameters of the message.

    • displayName: The video file name.
    • thumbnailLocalPath: The path of the thumbnail of the first frame of video.
    • duration: The video duration in seconds.
    • width: The video thumbnail width in pixels.
    • height: The video thumbnail height in pixels.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.
    • isOnline: Whether it is a online message.
    • deliverOnlineOnly: Whether the message is delivered only when the recipient(s) is/are online.
    • fileSize: The file size.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • filePath: string

      The path of the video file.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; displayName: string; duration: number; fileSize?: number; height: number; isChatThread?: boolean; isOnline?: boolean; thumbnailLocalPath: string; width: number }
      • Optional deliverOnlineOnly?: boolean
      • displayName: string
      • duration: number
      • Optional fileSize?: number
      • height: number
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean
      • thumbnailLocalPath: string
      • width: number

    Returns ChatMessage

    The message instance.

  • createVoiceMessage(targetId: string, filePath: string, chatType?: ChatMessageChatType, opt?: { deliverOnlineOnly?: boolean; displayName?: string; duration: number; fileSize?: number; isChatThread?: boolean; isOnline?: boolean }): ChatMessage
  • Creates a voice message for sending.

    params

    opt The extension parameters of the message.

    • displayName: The voice file name.
    • duration: The voice duration in seconds.
    • isChatThread: Whether this message is a threaded message.
      • true: Yes.
      • (Default) false: No.
    • isOnline: Whether it is a online message.
    • deliverOnlineOnly: Whether the message is delivered only when the recipient(s) is/are online.
    • fileSize: The file size.

    Parameters

    • targetId: string

      The user ID of the message recipient.

      • For a one-to-one chat, it is the user ID of the peer user.
      • For a group chat, it is the group ID.
      • For a chat room, it is the chat room ID.
    • filePath: string

      The path of the voice file.

    • chatType: ChatMessageChatType = ChatMessageChatType.PeerChat

      The conversation type. See {@link ChatType}.

    • Optional opt: { deliverOnlineOnly?: boolean; displayName?: string; duration: number; fileSize?: number; isChatThread?: boolean; isOnline?: boolean }
      • Optional deliverOnlineOnly?: boolean
      • Optional displayName?: string
      • duration: number
      • Optional fileSize?: number
      • Optional isChatThread?: boolean
      • Optional isOnline?: boolean

    Returns ChatMessage

    The message instance.

Generated using TypeDoc