CustomMessageContent

public abstract class CustomMessageContent extends MessageContent

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:

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

  2. 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))

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

Mention (@) info.

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

Mention (@) info.

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 setMentionedInfo(MentionedInfo mentionedInfo)

Mention (@) info.

Link copied to clipboard
public String toString()