SDKsAndroid
Send a message without OSS
Use sendMessageNotOss to send a media message whose resources were uploaded by your application.
Transmit a media message that already contains valid remote URLs, bypassing the SDK's built-in OSS upload pipeline. This method is typically used in conjunction with messages created from remote URLs (such as images, audio, video, or files created with create*MessageByURL). If the message was initialized from a local filesystem path, call the standard Send a message method instead.
Code example
String peerUserID = "user_b";
OfflinePushInfo offlinePushInfo = new OfflinePushInfo();
OpenIMClient.getInstance().messageManager.sendMessageNotOss(
new OnMsgSendCallback() {
@Override
public void onProgress(long progress) {
// Upload progress is typically not triggered since resources are already hosted
}
@Override
public void onSuccess(Message sentMessage) {
// Update local message state using sentMessage.getClientMsgID()
}
@Override
public void onError(int code, String error) {
// Handle send error and allow retry
}
},
message,
peerUserID,
null,
offlinePushInfo
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
callback | OnMsgSendCallback | Yes | Callback handler for message delivery events. |
message | Message | Yes | The message object to transmit, typically generated by a create*MessageByURL method. |
recvUid | String | Conditional | Recipient user ID for single chat. Pass null for group chat. |
recvGid | String | Conditional | Target group ID for group chat. Pass null for single chat. |
offlinePushInfo | OfflinePushInfo | No | Custom offline push notification payload. Pass null for default push configuration. |
Return value
Upon success, onSuccess returns the transmitted Message object.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the server accepted the message. The client should update the message status in the UI usingclientMsgID. - Asynchronous event delivery: Receiving clients receive the message asynchronously via
OnAdvanceMsgListener.onRecvNewMessage. See Receive messages for details.
Was this page helpful?