initShield static method

dynamic initShield(
  1. ShieldConfig config
)

Implementation

static initShield(ShieldConfig config) async {
  try {
    if (config.shieldCallback != null) {
      _channel.setMethodCallHandler(_methodHandler);
      _shieldCallback = config.shieldCallback;
    }
    String environment = "prod";
    switch (config.environment) {
      case ShieldEnvironment.dev:
        environment = "dev";
        break;
      case ShieldEnvironment.prod:
        environment = "prod";
        break;
      default:
        environment = "prod";
        break;
    }
    await _channel.invokeMethod("initShieldFraud", {
      "siteID": config.siteID,
      "key": config.key,
      "registerCallback": config.shieldCallback != null,
      "enableBackgroundListener": config.enableBackgroundListener,
      "enableMocking": config.enableMocking,
      "partnerId": config.partnerId,
      "environment": environment,
      "defaultBlockedDialog": config.defaultBlockedDialog != null
          ? {
              "title": config.defaultBlockedDialog!.title,
              "body": config.defaultBlockedDialog!.body,
            }
          : null,
      "logLevel": config.logLevel.toString()
    });
  } catch (_) {
    //something went wrong during initialization. nothing we can do
  }
  return;
}