Browse SDKs · Android
SDKsAndroid

Insert a local group message

Use insertGroupMessageToLocalStorage to insert a group message visible only on the current device.

Copy

insertGroupMessageToLocalStorage() writes a message to a group chat on the current device. Use it for imported records or application notices that must remain local. It does not send the message or synchronize it to other devices.

message is the complete message object, groupID identifies the target group, and senderUserID is the sender shown for the inserted message.

OpenIMClient.getInstance().messageManager.insertGroupMessageToLocalStorage(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Re-read or update the group message list on this device.
        }

        @Override
        public void onError(int code, String error) {
            // Report the local write failure.
        }
    },
    message,
    groupID,
    senderUserID
);

The success callback means the local write completed. This operation does not trigger a new-message event and cannot replace Send a message.