sendMediaMessage method
Future<Map>
sendMediaMessage(
- dynamic message,
- String toConversationID,
- dynamic conversationType,
- dynamic config,
- int messageID,
- int progressID,
- int messageAttachedCallbackID,
)
Implementation
Future<Map<dynamic, dynamic>> sendMediaMessage(
dynamic message,
String toConversationID,
dynamic conversationType,
dynamic config,
int messageID,
int progressID,
int messageAttachedCallbackID) async {
Object _message = mapToJSObj(message);
Object _config = mapToJSObj(config);
Map notification = {
'onMessageAttached':
allowInterop((message, currentFileSize, totalFileSize) {
ZIMMessageAttachedCallback? callback = ZIMCommonData
.zimMessageAttachedCallbackMap[messageAttachedCallbackID];
if (callback != null) {
ZIMMessage zimMessage = getZIMMessage(message);
callback(zimMessage);
}
}),
'onMediaUploadingProgress':
allowInterop((message, currentFileSize, totalFileSize) {
ZIMMediaDownloadingProgress? progress =
ZIMCommonData.mediaDownloadingProgressMap[progressID];
if (progress != null) {
ZIMMessage zimMessage = getZIMMessage(message);
progress(zimMessage, currentFileSize, totalFileSize);
}
})
};
ZIMMediaDownloadingProgress? progress =
ZIMCommonData.mediaDownloadingProgressMap[progressID];
final result = await promiseToFuture(ZIM.getInstance()!.sendMediaMessage(
_message,
toConversationID,
conversationType,
_config,
mapToJSObj(notification)))
.catchError((e) {
throw PlatformException(code: e.code.toString(), message: e.message);
});
return jsObjectToMap(result);
}