Let's say you want to implement a simple chat bubble like this, with RecyclerView ViewType and Kotlin:
When sending a message, fill in the key-value data in 'metaData' property which will be used for creating an UIView instance.
val metaData: HashMap<String, String> =hashMapOf()metaData.apply {put("type", "msg_with_button")put("title", "Hi!")put("body", "This is a simple chat bubble with a button.")put("button_text", "Say Hello")put("button_action", "SayHello")}val params: TPMessageSendParams= TPMessageSendParams.Builder(channel, TPMessageSendParams.MessageType.TEXT, TPMessageSendParams.ContentType.TEXT) .setText(textMessage) .setMentions(mentionsUserIDs) .setParentMessageId(parentMessageId) .setMetaData(metaData) .setFileUrl() .setTranslationLanguages(translationLanguages) .build()TalkPlus.sendMessage(params, object : TalkPlus.CallbackListener<TPMessage>() {overridefunonSuccess(tpMessage: TPMessage) { }overridefunonFailure(errorCode: Int, exception: Exception) { }})
You can enter up to 5 key-value pairs in data field. The maximum size of key is 128 characters and the maximum size of value is 1024 characters. Both key and value must be strings.
Define a 'CardViewMessageModel' data class that contains data to be displayed on the screen.
'messageReceived' method will be called whenever receiving a new message. At this method, call 'getData' method in 'TPMessage to get key-value data and then create an instance of 'CardViewMessageModel'.