setConsent method

  1. @override
Future<void> setConsent({
  1. bool? adStorageConsentGranted,
  2. bool? analyticsStorageConsentGranted,
  3. bool? adPersonalizationSignalsConsentGranted,
  4. bool? adUserDataConsentGranted,
  5. bool? functionalityStorageConsentGranted,
  6. bool? personalizationStorageConsentGranted,
  7. bool? securityStorageConsentGranted,
})
override

Sets the applicable end user consent state. By default, no consent mode values are set.

  • adStorageConsentGranted - Enables storage, such as cookies, related to advertising. (Platform: Android, iOS, Web)
  • analyticsStorageConsentGranted - Enables storage, such as cookies, related to analytics (for example, visit duration). (Platform: Android, iOS, Web)
  • adPersonalizationSignalsConsentGranted - Sets consent for personalized advertising. (Platform: Android, iOS, Web)
  • adUserDataConsentGranted - Sets consent for sending user data to Google for advertising purposes. (Platform: Android, iOS, Web)
  • functionalityStorageConsentGranted - Enables storage that supports the functionality of the website or app such as language settings. (Platform: Web)
  • personalizationStorageConsentGranted - Enables storage related to personalization such as video recommendations. (Platform: Web)
  • securityStorageConsentGranted - Enables storage related to security such as authentication functionality, fraud prevention, and other user protection. (Platform: Web)

Default consents can be set according to the platform:

Implementation

@override
Future<void> setConsent({
  bool? adStorageConsentGranted,
  bool? analyticsStorageConsentGranted,
  bool? adPersonalizationSignalsConsentGranted,
  bool? adUserDataConsentGranted,
  bool? functionalityStorageConsentGranted,
  bool? personalizationStorageConsentGranted,
  bool? securityStorageConsentGranted,
}) async {
  try {
    return channel.invokeMethod<void>(
      'Analytics#setConsent',
      <String, Object?>{
        if (adStorageConsentGranted != null)
          'adStorageConsentGranted': adStorageConsentGranted,
        if (analyticsStorageConsentGranted != null)
          'analyticsStorageConsentGranted': analyticsStorageConsentGranted,
        if (adPersonalizationSignalsConsentGranted != null)
          'adPersonalizationSignalsConsentGranted':
              adPersonalizationSignalsConsentGranted,
        if (adUserDataConsentGranted != null)
          'adUserDataConsentGranted': adUserDataConsentGranted,
      },
    );
  } catch (e, s) {
    convertPlatformException(e, s);
  }
}