CustomMediaMessageContent

public abstract class CustomMediaMessageContent extends MediaMessageContent

Base class for custom media message content.

Extend this class to define custom message types that require file uploads (e.g., custom images, custom files). The SDK handles registration, sending (including file upload), and decoding automatically — no internal SDK types are needed.

Compared to CustomMessageContent:

  • Inherits from MediaMessageContent, which provides localPath, remoteUrl, name, and other media properties

  • The SDK automatically handles file uploads when sending

Subclasses must:

  1. Provide a no-argument constructor (the SDK creates instances via reflection)

  2. Implement messageType, persistentFlag, encodeFields, decodeFields

Usage example:

class CustomFileMessage : CustomMediaMessageContent() {
var fileType: String = ""
var fileSize: Long = 0L

override fun messageType(): String = "app:customfile"

override fun persistentFlag(): Int = MessagePersistent.COUNT

override fun encodeFields(): Map<String, Any?> = mapOf(
"fileType" to fileType,
"fileSize" to fileSize
)

override fun decodeFields(fields: Map<String, Any?>) {
fileType = fields["fileType"] as? String ?: ""
fileSize = (fields["fileSize"] as? Number)?.toLong() ?: 0L
}
}

NCEngine.registerCustomMessages(listOf(CustomFileMessage::class.java))

Constructors

Inherited properties

Link copied to clipboard
private Long destructTime

Auto-destruct duration in seconds after the message is read.

Link copied to clipboard
private String extra

Extra data attached to the message content (sent along with the message, synced remotely).

Link copied to clipboard
private Boolean isDestruct

Whether this is a burn-after-reading message.

Link copied to clipboard
private String localPath

Local file path of the media content.

Link copied to clipboard

Mention (@) info.

Link copied to clipboard
private String name

Media content file name.

Link copied to clipboard
private String remoteUrl

Remote URL of the media content after upload.

Functions

Link copied to clipboard
public abstract Unit decodeFields(Map<String, Object> fields)

Decodes the message content from field data.

Link copied to clipboard
public abstract Map<String, Object> encodeFields()

Encodes the message content into serializable key-value pairs.

Link copied to clipboard
public abstract String messageType()

Message type identifier.

Link copied to clipboard
public abstract Integer persistentFlag()

Message storage policy flag.

Link copied to clipboard
public List<String> searchableWords()

Returns a list of keywords to be indexed for message search.

Inherited functions

Link copied to clipboard
public final Long getDestructTime()

Auto-destruct duration in seconds after the message is read.

Link copied to clipboard
public final String getExtra()

Extra data attached to the message content (sent along with the message, synced remotely).

Link copied to clipboard
public final String getLocalPath()

Local file path of the media content.

Link copied to clipboard

Mention (@) info.

Link copied to clipboard
public final String getName()

Media content file name.

Link copied to clipboard
public final String getRemoteUrl()

Remote URL of the media content after upload.

Link copied to clipboard
public final Boolean isDestruct()

Whether this is a burn-after-reading message.

Link copied to clipboard
public final Unit setDestruct(Boolean isDestruct)

Whether this is a burn-after-reading message.

Link copied to clipboard
public final Unit setDestructTime(Long destructTime)

Auto-destruct duration in seconds after the message is read.

Link copied to clipboard
public final Unit setExtra(String extra)

Extra data attached to the message content (sent along with the message, synced remotely).

Link copied to clipboard
public final Unit setLocalPath(String localPath)

Local file path of the media content.

Link copied to clipboard
public final Unit setMentionedInfo(MentionedInfo mentionedInfo)

Mention (@) info.

Link copied to clipboard
public final Unit setName(String name)

Media content file name.

Link copied to clipboard
public final Unit setRemoteUrl(String remoteUrl)

Remote URL of the media content after upload.

Link copied to clipboard
public String toString()