What's New

Implement a simple chat bubble with a button

Let's say you want to implement a simple chat bubble like this, with 'UIKit frameworkarrow-up-right' and Swift:

  1. When sending a message, fill in the key-value data in 'metaData' property which will be used for creating an UIView instance.

circle-info

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.

  1. Define a 'CardViewMessageModel' class that contains data to be displayed on the screen.

  1. Adopt 'TPChannelDelegate' protocol to your ViewController, and add required methods for this protocol.

  1. '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'.

  1. As a final step, you need to create a view and add it where you want. In the above example, 'CardViewMessageModel.addCardView' method creates a view and adds the created view to the parent view.

Last updated