Skip to main content

Message Download

Feature Description

  • The SDK provides functionalities for downloading, canceling, and pausing multimedia files.
  • For sending multimedia messages, refer to the "Sending Media Messages" section in Message Sending.

Download Multimedia Messages

Download multimedia files.

Method

Future<int> downloadMediaMessage(RCIMIWMediaMessage message, {RCIMIWDownloadMediaMessageListener? listener});

Parameter Description

ParameterTypeDescription
messageRCIMIWMediaMessageThe media message object to be downloaded
listenerRCIMIWDownloadMediaMessageListenerThe event listener for downloading media messages

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success, and the specific result needs to be implemented through the interface callback. Non-zero indicates that the current operation failed, and the interface callback will not be triggered. For detailed errors, refer to the error codes.

Code Example

RCIMIWDownloadMediaMessageListener? listener = RCIMIWDownloadMediaMessageListener(onMediaMessageDownloading: (RCIMIWMediaMessage? message, int? progress) {
//...
}, onDownloadingMediaMessageCanceled: (RCIMIWMediaMessage? message) {
//...
}, onMediaMessageDownloaded: (int? code, RCIMIWMediaMessage? message) {
//...
});

int? ret = await engine?.downloadMediaMessage(message, listener:listener);

Callback Methods

  • onMediaMessageDownloading

    The listener for the interface call result.

Function(RCIMIWMediaMessage? message, int? progress)? onMediaMessageDownloading;

Parameter Description

ParameterTypeDescription
messageRCIMIWMediaMessageThe message being downloaded
progressintThe download progress

Code Example

engine?.onMediaMessageDownloading = (RCIMIWMediaMessage? message, int? progress) {
//...
};
  • onMediaMessageDownloaded

    The listener for the interface call result.

Function(int? code, RCIMIWMediaMessage? message)? onMediaMessageDownloaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, and non-zero indicates an exception.
messageRCIMIWMediaMessageThe message that was downloaded

Code Example

engine?.onMediaMessageDownloaded = (int? code, RCIMIWMediaMessage? message) {
//...
};

Cancel Multimedia Message Download

Cancel the download of a multimedia message.

Method

Future<int> cancelDownloadingMediaMessage(RCIMIWMediaMessage message, {IRCIMIWCancelDownloadingMediaMessageCallback? callback});

Parameter Description

ParameterTypeDescription
messageRCIMIWMediaMessageThe media message object whose download is to be canceled
callbackIRCIMIWCancelDownloadingMediaMessageCallbackThe event callback for canceling the download of a media message. The SDK supports callback methods starting from version 5.3.1. Other callback methods for this interface are deprecated starting from version 5.4.0. If the callback parameter is provided, only the callback will be triggered.

Return Value

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success, and the specific result needs to be implemented through the interface callback. Non-zero indicates that the current operation failed, and the interface callback will not be triggered. For detailed errors, refer to the error codes.

Code Example

Return ValueDescription
Future<int>The status code of the current operation. 0 indicates success, and the specific result needs to be implemented through the interface callback. Non-zero indicates that the current operation failed, and the interface callback will not be triggered. For detailed errors, refer to the error codes.

Callback Methods

  • onDownloadingMediaMessageCanceled

The listener for the interface call result.

Function(int? code, RCIMIWMediaMessage? message)? onDownloadingMediaMessageCanceled;

Parameter Description

ParameterTypeDescription
codeintThe status code of the interface callback. 0 indicates success, and non-zero indicates an exception.
messageRCIMIWMediaMessageThe message whose download was canceled

Code Example

engine?.onDownloadingMediaMessageCanceled = (int? code, RCIMIWMediaMessage? message) {
//...
};