requestConsentInfoUpdate method

  1. @override
Future<void> requestConsentInfoUpdate(
  1. AdsConsentOptions options
)
override

Implementation

@override
Future<void> requestConsentInfoUpdate(AdsConsentOptions options) {
  final completer = Completer<void>();

  try {
    _consentInformation.requestConsentInfoUpdate(
      ConsentRequestParameters(
        tagForUnderAgeOfConsent: options.tagForUnderAgeOfConsent,
        consentSyncId: options.consentSyncId,
        consentDebugSettings:
            options.debugGeography == null && options.testDeviceIds.isEmpty
            ? null
            : ConsentDebugSettings(
                debugGeography: switch (options.debugGeography) {
                  null => DebugGeography.debugGeographyDisabled,
                  AdsConsentDebugGeography.disabled =>
                    DebugGeography.debugGeographyDisabled,
                  AdsConsentDebugGeography.eea =>
                    DebugGeography.debugGeographyEea,
                  AdsConsentDebugGeography.regulatedUsState =>
                    DebugGeography.debugGeographyRegulatedUsState,
                  AdsConsentDebugGeography.other =>
                    DebugGeography.debugGeographyOther,
                },
                testIdentifiers: options.testDeviceIds,
              ),
      ),
      () {
        if (!completer.isCompleted) completer.complete();
      },
      (error) {
        if (!completer.isCompleted) {
          completer.completeError(
            AdsConsentException('${error.errorCode}: ${error.message}'),
          );
        }
      },
    );
  } catch (error, stackTrace) {
    if (!completer.isCompleted) completer.completeError(error, stackTrace);
  }

  return completer.future;
}