Joke Collection Website - Blessing messages - Tencent Cloud Instant Messaging (3)-----Customized Messages

Tencent Cloud Instant Messaging (3)-----Customized Messages

Tencent Cloud IM’s SDK mainly provides the following message classes

TIMTextElem? (text message)

TIMImageElem? (picture message)

TIMFileElem? (File message)

TIMSoundElem (Voice message)

TIMLocationElem? (Geographical location)

TIMFaceElem? (Emoticon message type)

TIMVideoElem (micro video message)

TIMUGCElem? (UGC video)

Generally speaking, these message types can meet our needs, but products and bosses only It's the boss. They have made the plan, and the hard-working programmers have to work hard to implement it.

This is when custom messages come in handy. Let's take a look at this custom message class first. ? TIMCustomElem

It is obvious from the comments that one of the attributes is of NSData type?, that is, we need to convert the custom message encapsulation into NSData and pass it over.

According to the poster's needs It is necessary to customize a message to display order information. It is necessary to display the contact information of the orderer, address information consignee, product pictures, product price, product name and other information

Construction process

The format of the constructed message body is

In this way, the custom message insertion is successful, but in order to correctly display the custom message on the interface, a cell class for message display must be customized

p>

We add a class ChatCustomOrderTableViewCell to ChatTableViewCell and let it inherit from ChatBaseTableViewCell

//Then implement this class

//The pitfall encountered is that it was used when setting constraints before The layout has always been incorrect compared to the sibling controls. Later, this rigid layout was adopted to meet the requirements. . .