How to add 'Google Consent 'to flutter app

626

Main

pubspec.yaml

dependencies:
  admob_consent: '1.0.0' #if you will change the text
  admob_consent: ^1.0.0+1 #if you will use main

initialization

import 'package:flutter/material.dart';
import 'package:admob_consent/admob_consent.dart';

final AdmobConsent _admobConsent = AdmobConsent();

_admobConsent.show(publisherId: "REPLACE_WITH_YOUR_PUBLISHER_ID", privacyURL: "URL_TO_YOUR_PRIVACY_POLICY");

Listener

You can listen to the onConsentFormLoaded, onConsentFormOpened, onConsentFormClosed and onConsentFormError streams.

_admobConsent.onConsentFormClosed.listen((bool status) {
    // Status true if personalized
    // Handle it, ie. set targetingInfo
});

To use in Polish

When you want to use the plugin in polish, without creating a Google Founding Choices account, you need to use this version of the Plugin

Version: '1.0.0' (not the newest)

README.md from this commit here

Here you can edit the language files (External Libraries/Flutter Plugins/admob_consent-1.0.0/android/src.main/assets)

enter image description here

There are a couple html files, these represent the consent query. You can either copy and revise one of these, but then you have to make sure that you also integrate them.

Therefore, if the target group is only Polish, I would recommend working on one, for example English, and calling it up. (The code snippet you are looking for is at the ground of the files.)

Share:
626
Captivity
Author by

Captivity

Software developer, designer, webdev. Symfony, BPMS, BPM.

Updated on December 24, 2022

Comments

  • Captivity
    Captivity over 1 year

    In my application I use native ads from: firebase_admob, native_admob_controller, flutter_native_admob.

    child: NativeAdmob(
                  // Your ad unit id
                  adUnitID: adsAndroidID,
                  controller: _nativeAdController,
                  // Don't show loading widget when in loading state
                ),
    

    How can I now add to it the information described under this link https://developers.google.com/admob/ump/android/quick-start ?

    I trying run with https://pub.dev/packages/gdpr_dialog but this is only in english language.

  • Captivity
    Captivity over 3 years
    How to set a message in Polish?
  • Captivity
    Captivity over 3 years
    I dont have folder "assets". Where I can write text in polish?
  • m123
    m123 over 3 years
    So, I revised it again, I had used the wrong installation line for pubspec.yaml. I also explained it again in more detail. ; )