Message Sending
Method Description
Send method explanation:Send Text Message
Send Image Message
Self-uploaded Image
SDK Upload File
Need to implement file upload data source Reference: File Upload Data Source
Send Voice Message
Send Location Message
Send Custom Message
Reference custom messages: Custom MessagesMessage Listening
Listen for Message Send Status
Message Send Status Code (ReasonCode)
When a message is sent, thereasonCode in the SendackPacket returned by the addMessageStatusListener indicates the result of the message delivery. Below are the descriptions for each status code:
| Value | Name | Description |
|---|---|---|
| 0 | ReasonUnknown | Unknown error |
| 1 | ReasonSuccess | Success |
| 2 | ReasonAuthFail | Authentication failed |
| 3 | ReasonSubscriberNotExist | Subscriber does not exist in the channel |
| 4 | ReasonInBlacklist | In blacklist |
| 5 | ReasonChannelNotExist | Channel does not exist |
| 6 | ReasonUserNotOnNode | User is not on node |
| 7 | ReasonSenderOffline | Sender is offline, message delivery failed |
| 8 | ReasonMsgKeyError | Message key error, invalid message |
| 9 | ReasonPayloadDecodeError | Payload decoding failed |
| 10 | ReasonForwardSendPacketError | Forwarding send packet failed |
| 11 | ReasonNotAllowSend | Not allowed to send message |
| 12 | ReasonConnectKick | Connection kicked |
| 13 | ReasonNotInWhitelist | Not in whitelist |
| 14 | ReasonQueryTokenError | Query user token error |
| 15 | ReasonSystemError | System error |
| 16 | ReasonChannelIDError | Wrong channel ID |
| 17 | ReasonNodeMatchError | Node matching error |
| 18 | ReasonNodeNotMatch | Node not matched |
| 19 | ReasonBan | Channel is banned |
| 20 | ReasonNotSupportHeader | Unsupported header |
| 21 | ReasonClientKeyIsEmpty | clientKey is empty |
| 22 | ReasonRateLimit | Rate limit exceeded |
| 23 | ReasonNotSupportChannelType | Unsupported channel type |
| 24 | ReasonDisband | Channel disbanded |
| 25 | ReasonSendBan | Sending is banned |
Listen for Regular Messages
Listen for CMD Messages
Message History
Need to implement sync channel message data source Reference: Sync Channel Message Data Source
Get history messages for a channel:
History Message Loading Example
Offline Messages
In WuKongIM, to handle massive offline messages, an on-demand pull mechanism is adopted. For example, with 10 conversations each having 100,000 messages, WuKongIM will not pull all 1 million messages to local storage. Instead, it pulls information for these 10 conversations and the corresponding latest 20 messages, which means actually only 200 messages are pulled. Compared to 1 million messages, this greatly improves offline pull speed. Users will only pull messages for a specific conversation when they enter that conversation. These mechanisms are already encapsulated within the SDK, so users don’t need to worry about them. Users only need to focus on recent conversation changes.Offline Message Sync Example
Best Practices
1. Message Deduplication
2. Message Status Handling
3. Memory Management
Next Steps
Channel Management
Learn how to manage channels and groups
Conversation Management
Handle conversation lists and unread messages
Data Source Configuration
Configure data sources and sync logic
Advanced Features
Explore advanced features and custom messages

