TUIChat accommodates the inclusion of images in these formats as custom emoticons: JPEG, JPG, PNG, BMP. GIF format is also supported, which starts from version 7.8.
Adding a Custom Emoji
TUIChat allows for adding custom emojis from the sandbox, assets directory, and network paths.
The following takes adding the programmer emoji from the assets directory as an example.
Preparing sticker resources
Create the assets folder in the src/main folder of the app and put the emoji folder in the assets directory:
Adding a sticker
When the application starts, call the API to add a custom emoji to FaceManager:
Each sticker has a unique faceGroupID, and each emoji in the sticker has a faceKey. After the sticker is added to FaceManager, stickers will be sorted by faceGroupID on the More emojis input UI.
publicclassDemoApplicationextendsApplication{
@Override
publicvoidonCreate(){
FaceGroup programmerGroup =newFaceGroup();
// The number of emojis displayed per row on the **More emojis** input UI
After a custom emoji message is received, TUIKit will parse the V2TIMMessage of the IM SDK as the FaceMessageBean type. FaceMessageBean can be used to get the faceGroupID and faceKey of the custom emoji.
After the faceGroupID and faceKey of a custom emoji are obtained, the loadFace method of FaceManager can be called to load them to the imageView passed in: