init method

  1. @override
Future init(
  1. Map<String, dynamic> config
)
override

Implementation

@override
Future<dynamic> init(Map<String, dynamic> config) async {
  var apiKey = config[ConstantKeys.apiKey];
  if (apiKey == null && apiKey is! String) {
    throw Exception(
      "apiKey is required and need to be a string but got: $apiKey",
    );
  }

  var contactIdentifier = config[ConstantKeys.contactIdentifier];
  if (contactIdentifier == null && contactIdentifier is! String) {
    throw Exception(
      "contactIdentifier is required and need to be a string but got: $contactIdentifier",
    );
  }

  var userId = config[ConstantKeys.userId];
  if (userId == null && userId is! String) {
    throw Exception(
      "userId is required and need to be a string but got: $userId",
    );
  }

  this.contactIdentifier = contactIdentifier;
  this.userId = userId;

  if (_channel != null) {
    _channel?.sink.close();
  }

  connect(apiKey);
}