startChatProviders method

Future<void> startChatProviders({
  1. bool autoConnect = true,
})

Start chat providers for custom UI handling

periodicRetrieve periodic time to update the providersStream

autoConnect Determines if you also want to connect to the chat socket

The user will not receive push notifications while connected

Implementation

Future<void> startChatProviders({bool autoConnect = true}) async {
  try {
    if (!_isStreaming) {
      _providersStream = StreamController<ChatProviderModel>();
      _connectionStatusStream = StreamController<CONNECTION_STATUS>();
      _chatSettingsStream = StreamController<ChatSettingsModel>();
      _chatAccountStream = StreamController<ChatAccountModel>();
      _isStreaming = true;
    }

    await _channel.invokeMethod('startChatProviders');

    if (autoConnect) {
      await connect();
    }
  } catch (e) {
    print(e);
  }
}