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