Browse SDKs · Android
SDKsAndroid

Set local message extensions

Use setMessageLocalEx to store message data used only on the current device.

Copy

setMessageLocalEx() stores an application-defined string on one message on the current device. Use localEx for local information such as a download path or playback state. It is not synchronized to the server, other devices, or other users.

conversationID and clientMsgID identify the message. If localExJson contains JSON, serialize it before the call and validate its structure when reading it.

OpenIMClient.getInstance().messageManager.setMessageLocalEx(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Update this message's localEx in the current device UI.
        }

        @Override
        public void onError(int code, String error) {
            // Keep the previous value and report the failure.
        }
    },
    conversationID,
    clientMsgID,
    localExJson
);

The success callback means the local extension was saved. This operation does not modify the message body or trigger a shared message event.