# Class AdConsent

java.lang.Object
com.codename1.ads.AdConsent

public final class AdConsent extends java.lang.Object

Manages user privacy consent for advertising. On modern platforms collecting consent is mandatory before personalized ads can be served: in the EEA/UK the GDPR consent form must be shown (the provider wraps Google's User Messaging Platform or an equivalent), and on iOS the App Tracking Transparency prompt must be presented to access the advertising identifier.

The recommended flow is: initialize the `AdManager`, request consent, then load ads only once consent has been resolved:

    AdManager.initialize(new AdConfig(), ok ->
        AdConsent.requestConsent(status -> {
            if (AdConsent.canRequestAds()) {
                interstitial.load();
            }
        }));

When no provider is registered consent calls resolve immediately to `STATUS_NOT_REQUIRED`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `STATUS_NOT_REQUIRED`
  Consent is not required for this user (e.g. outside the EEA).
  `static final int`
  `STATUS_OBTAINED`
  Consent was obtained.
  `static final int`
  `STATUS_REQUIRED`
  Consent is required and has not yet been obtained.
  `static final int`
  `STATUS_UNKNOWN`
  Consent status is unknown (consent has not been requested yet).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `canRequestAds()`
  True when there is enough consent to request ads.
  `static int`
  `getConsentStatus()`
  The current consent status without triggering a new request.
  `static void`
  `requestConsent(AdCallback<Integer> onComplete)`
  Gathers consent if required, presenting the consent form and (on iOS) the App Tracking Transparency prompt as needed.
  `static void`
  `reset()`
  Clears stored consent.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### STATUS_UNKNOWN

    public static final int STATUS_UNKNOWN
    Consent status is unknown (consent has not been requested yet).
    See Also:
      - Constant Field Values

  - ### STATUS_REQUIRED

    public static final int STATUS_REQUIRED
    Consent is required and has not yet been obtained.
    See Also:
      - Constant Field Values

  - ### STATUS_NOT_REQUIRED

    public static final int STATUS_NOT_REQUIRED
    Consent is not required for this user (e.g. outside the EEA).
    See Also:
      - Constant Field Values

  - ### STATUS_OBTAINED

    public static final int STATUS_OBTAINED
    Consent was obtained.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### requestConsent

    public static void requestConsent(AdCallback<Integer> onComplete)

    Gathers consent if required, presenting the consent form and (on iOS) the App Tracking Transparency prompt as needed. The callback receives one of the `STATUS_*` constants on the EDT when the flow completes.

    ###### Parameters

    - `onComplete`: invoked with the resulting consent status, may be null

  - ### canRequestAds

    public static boolean canRequestAds()
    True when there is enough consent to request ads. When no provider is installed this returns true so the simulator placeholder flow works.

  - ### getConsentStatus

    public static int getConsentStatus()
    The current consent status without triggering a new request.

  - ### reset

    public static void reset()
    Clears stored consent. Intended for testing the consent flow only.