In WuKongIM, all message types are custom messages
Custom Messages
Custom Regular Messages
Below we use business card messages as an example.Step 1: Define Message
Define a message object that inherits fromWKMessageContent and specify the message type in the constructor.
Step 2: Encoding and Decoding
We need to send uid, name, avatar three field information to the recipient. The final message content passed is:encodeJson and decodeJson methods of WKMessageContent to start encoding and decoding:
When encoding and decoding messages, there’s no need to consider the
type field, as the SDK handles it internallyStep 3: Register Message
Complete Business Card Message Implementation
Custom Attachment Messages
Sometimes we need to send messages with attachments when sending messages. WuKongIM also provides custom attachment messages, which are not much different from regular messages. Below we use location messages as an example.Step 1: Define Message
Note that custom attachment messages need to inherit fromWKMediaMessageContent instead of WKMessageContent.
WKMediaMessageContent provides url and localPath fields, so custom messages don’t need to define network address and local address fields againStep 2: Encoding and Decoding
We need to sendlongitude, latitude, address, url information to the recipient. The final message content passed is:
encodeJson and decodeJson methods of WKMessageContent to start encoding and decoding:
Step 3: Register Message
Message Extensions
As business develops, applications have increasingly more features in chat. To meet most requirements, WuKongIM has added message extension functionality. Message extensions are divided intolocal extensions and remote extensions. Local extensions are only for local app use and will be lost after uninstalling the app. Remote extensions are saved on the server and data will be restored after uninstalling and reinstalling.
Local Extensions
Local extensions are thelocalExtraMap field in the message object WKMsg.
After successful update, the SDK will trigger a refresh message callback
Remote Extensions
Remote extensions are theremoteExtra field in the message object WKMsg.
After successful update, the SDK will trigger a refresh message callback
Message Read/Unread
Message read/unread is also called message receipts. Message receipt functionality can be set through settings.syncMessageExtra. At this time, you need to sync the latest message extensions and save them to the SDK.
Message Reply
In chat, if there are too many messages, sending message replies will make the messages very messy and hard to follow. At this time, you need to make specific replies to certain messages, which is message reply. When sending a message, you just need to assign theWKReply object in the message content WKMessageContent to achieve the message reply effect.
WKReply Structure Description
Message Reactions (Likes)
Save
The same user can only make one reaction to the same message. Repeated reactions with different emojis to the same message will be treated as modifying the reaction, while repeated reactions with the same emoji will be treated as deleting the reaction
Get
WKMsgReaction Data Structure Description
Complete Advanced Features Manager
Next Steps
Data Source Configuration
Return to data source configuration
Message Management
Return to message handling functionality
Channel Management
Return to channel management functionality
Basic Features
Return to basic features
Summary
HarmonyOS SDK has now completed all core functionality documentation: ✅ Integration Guide - Complete installation and configuration guidance✅ Basic Features - Connection management and basic APIs
✅ Message Management - Message sending/receiving and history messages
✅ Channel Management - Channel information and member management
✅ Conversation Management - Conversation lists and unread messages
✅ Data Source Configuration - File upload and data synchronization
✅ Advanced Features - Custom messages and extension features HarmonyOS SDK documentation is now fully complete, providing developers with comprehensive technical guidance from beginner to advanced levels! 🎉

