CustomMessageContent

public abstract class CustomMessageContent extends MessageContent

Custom Normal Message content base class.

Business party Inherits This class from Define Custom Message class type, SDK internal Responsible for Register, Send and Receive Decode. no need to access internal SDK any Type.

Subclass need:

  1. Provides no-argument Constructor (SDK Via reflection Create instance)

  2. Implements 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 = MessageFlag.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))
NCEngine.registerCustomMessages(listOf(CardMessage::class.java))

Message type identifier.

Constructors

Inherited properties

Link copied to clipboard
private Long destructTime

after reading i.e. burn-after-reading destroy When time (Unit: seconds), message Read after passing This When destroy after time

Link copied to clipboard
private String extra

Message content extra data (follow message Send, Sync Remote)

Link copied to clipboard
private Boolean isDestruct

Whether after reading i.e. burn message

Link copied to clipboard

@ mention Info

Functions

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

Receive message When Call, From JSON Field data restore Custom message's Property.

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

Send message When Call, Convert Custom message Field Convert to serializable key-value Field.

Link copied to clipboard
public abstract String messageType()

Not can by "RC:" prefix ("RC:" official reserved prefix).

Link copied to clipboard
public abstract Integer persistentFlag()

See MessageFlag Constants:

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

Used for Message search Feature, Returns need Was/were indexed keyword.

Inherited functions

Link copied to clipboard
public final Long getDestructTime()

after reading i.e. burn-after-reading destroy When time (Unit: seconds), message Read after passing This When destroy after time

Link copied to clipboard
public final String getExtra()

Message content extra data (follow message Send, Sync Remote)

Link copied to clipboard

@ mention Info

Link copied to clipboard
public final Boolean isDestruct()

Whether after reading i.e. burn message

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

Whether after reading i.e. burn message

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

after reading i.e. burn-after-reading destroy When time (Unit: seconds), message Read after passing This When destroy after time

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

Message content extra data (follow message Send, Sync Remote)

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

@ mention Info

Link copied to clipboard
public String toString()