SDKsAndroid
Insert a local group message
Use insertGroupMessageToLocalStorage to insert a group message visible only on the current device.
Write a pre-constructed message directly into the local SQLite database of the current device for a group conversation. This operation does not issue a network request to the server, does not dispatch messages to other group members, and does not persist to cloud storage. It is suitable for displaying group join safety notices, local event announcements, or device-specific system logs. To send an actual message to all group members across the network, call Send a message.
Code example
String groupID = "group_123";
String senderUserID = "user_a";
OpenIMClient.getInstance().messageManager.insertGroupMessageToLocalStorage(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Message written to local storage, refresh group chat UI
}
@Override
public void onError(int code, String error) {
// Handle insertion failure
}
},
message,
groupID,
senderUserID
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
message | Message | Yes | Pre-constructed message object (typically created via one of the create*Message APIs). |
groupID | String | Yes | Globally unique ID of the target group. |
sender | String | Yes | User ID designated as the sender of the message. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback confirms that the message record was written to the local database. Insert the message into your group chat UI timeline usingclientMsgID. - Local scope: This is a local-only operation that does not persist to the server, does not dispatch to other group members, and does not fire
OnAdvanceMsgListener.onRecvNewMessageevents. - Re-query calibration: The message exists only on the current device. It will not synchronize across devices logged into the same account or appear in cloud roaming history.
Was this page helpful?