createConversation method

Future<VIConversationEvent> createConversation(
  1. VIConversationConfig config
)

Create a new conversation with the extended configuration.

Other parties of the conversation (online participants and logged in clients) can be informed about the conversation creation via the VIMessenger.onCreateConversation callback.

conversationConfig - VIConversationConfig instance with extended conversation parameters

Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError

Implementation

Future<VIConversationEvent> createConversation(
  VIConversationConfig config,
) async {
  try {
    Map<String, dynamic>? data = await _methodChannel.invokeMapMethod(
        'Messaging.createConversation', {'config': config._toMap});
    if (data == null) {
      _VILog._e('VIMessenger: createConversation: data was null, skipping');
      throw VIException(
        VIMessagingError.ERROR_INTERNAL,
        'VIMessenger:createConversation: data was null',
      );
    }
    return VIConversationEvent._fromMap(data);
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}