public final class AnalyticsConsent

  1. Object
  2. AnalyticsConsent
An immutable snapshot of the consent the user has granted, broken down by category so that an application can honour granular choices (for example allowing crash reporting while declining behavioural analytics). Instances are created through all(), none() or builder() and handed to Analytics.setConsent(AnalyticsConsent). An application that has already collected consent elsewhere can unblock everything in one line: Analytics.setConsent(AnalyticsConsent.all()).

Nested types

class AnalyticsConsent.BuilderMutable builder for AnalyticsConsent.

Methods

public boolean isAnalytics()Consent for screen views, events and user properties.
public boolean isCrashReporting()Consent for crash and exception reporting.
public boolean isPersonalization()Consent for personalization (e.g. user-level identification).
public boolean isAdStorage()Consent for advertising / ad storage.
public static AnalyticsConsent all()A consent object granting every category.
public static AnalyticsConsent none()A consent object denying every category.
public static AnalyticsConsent granted()Alias for all(); granting every category.
public static AnalyticsConsent denied()Alias for none(); denying every category.
public static AnalyticsConsent.Builder builder()Creates a builder seeded with all categories denied.
public AnalyticsConsent.Builder asBuilder()Returns a builder seeded with this object’s current values so a single category can be toggled without rebuilding from scratch.

Inherited methods

Method details

isAnalytics

public boolean isAnalytics()
Consent for screen views, events and user properties.

Returns

true if behavioural analytics collection is permitted

isCrashReporting

public boolean isCrashReporting()
Consent for crash and exception reporting.

Returns

true if crash reporting is permitted

isPersonalization

public boolean isPersonalization()
Consent for personalization (e.g. user-level identification).

Returns

true if personalization is permitted

isAdStorage

public boolean isAdStorage()
Consent for advertising / ad storage.

Returns

true if ad storage is permitted

all

public static AnalyticsConsent all()

A consent object granting every category. Use this when the application has already obtained consent through its own mechanism (a custom prompt, a third-party consent-management platform, an enterprise MDM policy, or a jurisdiction where the integrator has determined consent is not required) and simply wants reporting to flow:

// app handled consent elsewhere -- unblock all categories at startup
Analytics.setConsent(AnalyticsConsent.all());

For apps that would rather not gate at all, see Analytics.setConsentMode(ConsentMode) with ConsentMode.OPT_OUT.

Returns

consent with all categories granted

none

public static AnalyticsConsent none()
A consent object denying every category. Equivalent to the implicit state before consent is recorded in ConsentMode.OPT_IN.

Returns

consent with all categories denied

granted

public static AnalyticsConsent granted()
Alias for all(); granting every category.

Returns

consent with all categories granted

denied

public static AnalyticsConsent denied()
Alias for none(); denying every category.

Returns

consent with all categories denied

builder

public static AnalyticsConsent.Builder builder()
Creates a builder seeded with all categories denied.

Returns

a new builder

asBuilder

public AnalyticsConsent.Builder asBuilder()
Returns a builder seeded with this object’s current values so a single category can be toggled without rebuilding from scratch.

Returns

a builder pre-populated from this instance