Custom Media Message Content
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:
Provide a no-argument constructor (the SDK creates instances via reflection)
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))Inherited properties
Functions
Decodes the message content from field data.
Encodes the message content into serializable key-value pairs.
Message type identifier.
Message storage policy flag.
Returns a list of keywords to be indexed for message search.
Inherited functions
Auto-destruct duration in seconds after the message is read.
Local file path of the media content.
Mention (@) info.
Remote URL of the media content after upload.
Whether this is a burn-after-reading message.
Whether this is a burn-after-reading message.
Auto-destruct duration in seconds after the message is read.
Local file path of the media content.
Mention (@) info.
Remote URL of the media content after upload.