Sync sent messages to the sender's client
When your app server sends messages via the server API, you typically want the sender's client to also receive the sent message. Common scenarios include:
- Online sync: The sender's client is online and receives the message in real time.
- Offline catch-up: The sender's client comes online later and receives the message automatically.
- History retrieval: The sender's client can retrieve the message from message history.
Use the following approaches to achieve this:
- Set
isEchoToSenderto1— the server syncs the message to the sender's client when online. - Enable multi-device sync — offline clients automatically receive the message on reconnection.
- Enable cloud message history storage — clients can retrieve the message from history.
By default, Nexconn does not sync messages sent via the server API to the sender's client, nor does it store them in the sender's server-side message history.
Set the isEchoToSender parameter
When calling a send message API, set isEchoToSender to 1 to sync the message to the sender's client while online. Some APIs use isSyncSender with the same effect.
If omitted, the default value is 0 (no sync), and the sender's client does not receive the message.
APIs supporting isEchoToSender:
- Send a direct message
- Send a group channel message
- Send an open channel message
- Broadcast to all open channels
APIs supporting isSyncSender:
Enable multi-device sync
When a message is sent via the server API, the sender's client may be offline. Even with isEchoToSender set to 1, the server cannot sync the message in real time.
To allow offline clients to receive the message on reconnection, enable Message synchronization under Chat > Chat settings > Multi Client. Messages are delivered through the missed message compensation mechanism, which syncs messages from the last 1 calendar day (including today) by default.
Enable multi-device sync in the console. See Message management service configuration.
This approach only works for direct and group channels (open channels and community channels do not support missed message compensation):
Enable cloud message history storage
Your app may also need to retrieve messages sent via the server API through message history. For example, the sender may not log in for an extended period (causing missed messages to expire), or may accidentally delete messages locally.
To address this, enable cloud message history storage:
- Direct and Group Channel Cloud Message Storage: Messages sent via the server API are stored in the sender's server-side history for 6 months by default. The
isEchoToSenderparameter must be set to1at send time for the message to be stored. - Open Channel Cloud Message Storage: Messages are stored for 2 months by default. The
isEchoToSenderparameter must be set to1.
Enable these services in the console. See Message management service configuration.
Supported APIs:
Exceptions
Open channel broadcast messages cannot be stored in server-side history — they only sync to the sender's client when online.
Community channels have message history storage enabled by default (7 days). The isEchoToSender parameter is not supported. The sender can always retrieve messages sent via the server API from history.