Skip to main content

Message Sending

Method Description

Send method explanation:
Example usage:

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 Messages

Message Listening

Listen for Message Send Status

Add listener:
Remove listener:

Message Send Status Code (ReasonCode)

When a message is sent, the reasonCode in the SendackPacket returned by the addMessageStatusListener indicates the result of the message delivery. Below are the descriptions for each status code:

Listen for Regular Messages

Add listener:
Remove listener:

Listen for CMD Messages

Add listener:
Remove listener:

Message History

Need to implement sync channel message data source Reference: Sync Channel Message Data Source Get history messages for a channel:
Options parameter explanation:
Detailed explanation:

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