Custom Message Content
Base class for custom message content.
Extend this class to define custom message types. The SDK handles registration, sending, and decoding automatically — no internal SDK types are needed.
Subclasses must:
Provide a no-argument constructor (the SDK creates instances via reflection)
Implement messageType, persistentFlag, encodeFields, decodeFields
Usage example:
class CardMessage : CustomMessageContent() {
var title: String = ""
var imageUrl: String = ""
var linkUrl: String = ""
override fun messageType(): String = "app:card"
override fun persistentFlag(): Int = MessagePersistent.COUNT
override fun encodeFields(): Map<String, Any?> = mapOf(
"title" to title,
"imageUrl" to imageUrl,
"linkUrl" to linkUrl
)
override fun decodeFields(fields: Map<String, Any?>) {
title = fields["title"] as? String ?: ""
imageUrl = fields["imageUrl"] as? String ?: ""
linkUrl = fields["linkUrl"] as? String ?: ""
}
}
NCEngine.registerCustomMessages(listOf(CardMessage::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.
Mention (@) info.
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.
Mention (@) info.