init method

Future<void> init(
  1. PamConfig config,
  2. bool debug
)

Implementation

Future<void> init(PamConfig config, bool debug) async {
  WidgetsFlutterBinding.ensureInitialized();
  PamFlutterPlatform.instance.setOnPlatformCallback(methodsHandler);

  trackerAPI = TrackerAPI(config.pamServer);
  this.config = config;
  isEnableLog = debug;

  var allow = await pref.getBool(SaveKey.allowTracking);
  if (allow != null) {
    allowTracking = allow;
  }

  var status = await _loadConsentStatus(config.trackingConsentMessageID);
  var isAllowPreferences =
      status.trackingPermission?.preferencesCookies ?? false;

  if (isAllowPreferences) {
    allowTracking = true;
    pref.saveBool(true, SaveKey.allowTracking);
  } else {
    pref.saveBool(false, SaveKey.allowTracking);
  }

  var token = await pref.getString(SaveKey.pushKey);
  if (token != null) {
    Pam.setPushNotificationToken(token);
  }
}