start method

void start()

Prepares necessary infrastructure to communicate with native side and launches Talsec on native to check device for threats.

Implementation

void start() {
  /// Android device
  final AndroidConfig? androidConfig = _config.androidConfig;
  final IOSconfig? iosConfig = _config.iosConfig;

  if (Platform.isAndroid && androidConfig != null) {
    _configChannel.invokeListMethod<void>('setConfig', <String, dynamic>{
      'expectedPackageName': androidConfig.expectedPackageName,
      'expectedSigningCertificateHash':
          androidConfig.expectedSigningCertificateHash,
      'watcherMail': _config.watcherMail,
      'supportedAlternativeStores': androidConfig.supportedAlternativeStores
    });
  }

  /// iOS device
  else if (Platform.isIOS && iosConfig != null) {
    _configChannel.invokeListMethod<void>('setConfig', <String, String?>{
      'appBundleId': iosConfig.appBundleId,
      'appTeamId': iosConfig.appTeamId,
      'watcherMail': _config.watcherMail,
    });
  } else {
    throw MissingPluginException(
        '${Platform.isAndroid ? "androidConfig" : "IOSconfig"} is not provided.');
  }

  /// Listen to changes from native side
  _setListener(_channel);
}