Browse SDKs · Android
SDKsAndroid

Send a message without OSS

Use sendMessageNotOss to send a media message whose resources were uploaded by your application.

Copy

Use sendMessageNotOss() when the message already contains valid remote media URLs, so the SDK does not upload the files again. Pair it only with media messages created by create*MessageByURL(). Send local-path or local-file messages through Send a message.

Set only recvUid for a one-to-one chat or only recvGid for a group chat. offlinePushInfo controls the push content used while the recipient is offline.

OpenIMClient.getInstance().messageManager.sendMessageNotOss(
    new OnMsgSendCallback() {
        @Override
        public void onSuccess(Message sentMessage) {
            // Replace the pending item by clientMsgID.
        }

        @Override
        public void onError(int code, String error) {
            // Mark the item as failed and allow retry.
        }
    },
    message,
    peerUserID,
    null,
    offlinePushInfo
);

The success callback provides the sent Message and means this send request completed; it does not mean that a recipient event has arrived. See Receive messages for recipient handling.