capacitor-community / admob

Community plugin for using Google AdMob
MIT License
219 stars 68 forks source link

[Question] [Feature Request] User Consent via UMP (GDPR compliant) #142

Closed Syrex-o closed 1 year ago

Syrex-o commented 2 years ago

Hey, thanks for the amazing plugin. Appreciate your work :)

It seems like google updated the requirements for serving ads in the European Economic Area (EEA). Their Admob network now requires to present a consent message to the user via their User Messaging Platform (UMP) UMP Consent

Are you planning to implement this, to match the current regulations?

I know, there is an cordova implementation of this: cordova-plugin-consent But I´m not quite sure, if this is applicable for the new consent platform from google.

Even if I would skip all this and just accept so serve non-personalized-ads, AdMob states I have to get the user consent:

Although non-personalized ads don’t use cookies or mobile ad identifiers for ad targeting, they do still use cookies or mobile ad identifiers for frequency capping, aggregated ad reporting, and to combat fraud and abuse. Therefore, you must obtain consent to use cookies or mobile ad identifiers for those purposes where legally required, per the ePrivacy Directive in certain EEA countries.

Reference

distante commented 2 years ago

I am not sure if you are required to use the UMP, it just says you have to check for consent.

What I do in my app is to show a privacy dialog on the first run so the user can activate or deactivate the consent, It also shows my privacy policy and details.

The consent can always be retired.

I do NOT do any AdMob calls until the user chooses to accept or not personalized ads, and has accepted the privacy policy.

Syrex-o commented 2 years ago

Hey,

Just saw you're also from Germany. So same struggles probably.

I think your approach is not enough anymore. My research resulted in the following:

At least, those are the points, that come up for the UMP consent. I might overestimate the importance of this?

Can you drop further details of your implementation? Or could you please drop me a message ?

I think there is so much room of confusion around this topic.

distante commented 2 years ago

Mmm, I am not sure about the partners. Maybe you are right. It is really hard to get or find a direct question about that (I struggle with the same thing).

Maybe it would be good to implement that but at least from my end I do not have too much time to look at it at the moment :/

ivanov84 commented 1 year ago

Google require to implement UMP ASAP: 2023-06-17_11-03-35

ivanov84 commented 1 year ago

If anyone needs a quick solution, here is my code with a CustomCapacitorPlugin.java:

private ConsentInformation loadedConsentInformation;
private ConsentForm loadedConsentForm;

@PluginMethod()
public void showAdmobConsent(PluginCall call) {

    //Log.i("IVANOV-CONSENT","IvanovCustomCapacitorPlugin showAdmobConsent");

    /*ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(getContext())
            .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
            //.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_DISABLED)
            //.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_NOT_EEA)
            .addTestDeviceHashedId("xxx")
            .build();

    ConsentRequestParameters params = new ConsentRequestParameters
            .Builder()
            .setConsentDebugSettings(debugSettings)
            .build();*/

    ConsentRequestParameters params = new ConsentRequestParameters
            .Builder()
            .setTagForUnderAgeOfConsent(false)
            .build();

    loadedConsentInformation = UserMessagingPlatform.getConsentInformation(getContext());
    loadedConsentInformation.requestConsentInfoUpdate(getActivity(),
            params,
            () -> {
                //Log.i("IVANOV-CONSENT","IvanovCustomCapacitorPlugin showAdmobConsent onConsentInfoUpdateSuccess");
                //loadedConsentInformation.reset();
                if (loadedConsentInformation.isConsentFormAvailable()) {
                    loadForm(call);
                }
                else {
                    returnGrantedResult(call, false);
                }
            },
            formError -> {
                //Log.i("IVANOV-CONSENT","IvanovCustomCapacitorPlugin showAdmobConsent onConsentInfoUpdateFailure");
                returnGrantedResult(call, false);
            });
}

private void loadForm(PluginCall call) {
    UserMessagingPlatform.loadConsentForm(
            getContext(),
            consentForm -> {
                loadedConsentForm = consentForm;
                if (loadedConsentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
                    consentForm.show(
                            getActivity(),
                            formError -> returnGrantedResult(call,
                                    loadedConsentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.OBTAINED));
                }
            },
            formError -> returnGrantedResult(call, false)
    );
}

private void returnGrantedResult(PluginCall call, boolean granted) {
    JSObject ret = new JSObject();
    ret.put("granted", granted);
    call.resolve(ret);
}
kyoz commented 1 year ago

For anyone who is in rush, you can use my build in this PR. View the README.md in changes for usage example.

DiogoParrinha commented 1 year ago

@distante any idea when we'll have a new release? :D

distante commented 1 year ago

@distante any idea when we'll have a new release? :D

Sadly no, I have no control over the releases.

If you are in a hurry, you can put the repo as source for the plugin on your package.json.