initialize static method

Future<bool> initialize({
  1. required String appId,
  2. String? userConsent,
  3. String? subjectToGDPR,
  4. String? subjectToCCPA,
})

Implementation

static Future<bool> initialize(
    {required String appId,
    String? userConsent,
    String? subjectToGDPR,
    String? subjectToCCPA}) async {
  MethodChannel _channel = const MethodChannel('admost_flutter');

  if (appId == null) {
    print("appId cannot be null!");
    return false;
  }
  _sharedInstance.appId = appId;
  Map<String, String> config = {
    "appId": appId,
  };
  if (userConsent != null) {
    config["userConsent"] = userConsent;
  }
  if (subjectToGDPR != null) {
    config["subjectToGDPR"] = subjectToGDPR;
  }
  if (subjectToCCPA != null) {
    config["subjectToCCPA"] = subjectToCCPA;
  }

  try {
    final bool? result =
        (await _channel.invokeMethod<bool>('initialize', config));
    return result ?? false;
  } catch (e) {
    print("<ADMOST> initialize erorr: ${e}");
    return false;
  }
}