При попытке проверить согласие пользователя на соответствие требованиям ЕС «requestConsentInfoUpdated» не вызывается - PullRequest
0 голосов
/ 04 марта 2020

В настоящее время я внедряю библиотеку согласия для соответствия нормативам EUP EUR и следую инструкциям Google. К сожалению, форма согласия не отображается.

В своих журналах я вижу, что consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() в методе checkUserConsent не вызывается, поэтому я думаю, что что-то не так с моим идентификатором издателя или информацией о согласии. Мой идентификатор правильный, поэтому ошибка может быть только в праве на информацию о согласии?

Я использую «часто используемый набор провайдеров рекламных технологий» в Admob, но также изменил на другой вариант и выбрал только Google, так как кажется, что есть проблема, но изменение не решило проблему.

В настоящее время я не работаю со своим приложением, я нахожусь во Внутреннем тестировании, поэтому я использую тестовые объявления прямо сейчас, будет ли Форма согласия будет видна только в том случае, если я использую реальную рекламу?

Редактировать:

Вот ошибка, которую я получаю в методе onFailedToUpdateConsentInfo:

Could not parse Event FE preflight response.

Но я использую правильные идентификаторы издателей.

Любая помощь очень ценится!

Вот моя реализация:

...
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
...
        checkUserConsent();

...
    }

    private void checkUserConsent() {

        ConsentInformation consentInformation = ConsentInformation.getInstance(this);
        String[] publisherIds = {"my Pub-Id"};
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {

            @Override
            public void onConsentInfoUpdated(ConsentStatus consentStatus) {
                // User's consent status successfully updated.
                Log.e("tag", "2");
                if (ConsentInformation.getInstance(getBaseContext()).isRequestLocationInEeaOrUnknown()) {
                    switch (consentStatus) {
                        case UNKNOWN:
                            consentForm();
                            break;
                        case PERSONALIZED:
                            initializeAds(true);
                            break;
                        case NON_PERSONALIZED:
                            initializeAds(false);
                            break;
                    }
                } else {
                    Log.e("tag", "3");
                }
            }


            @Override
            public void onFailedToUpdateConsentInfo(String errorDescription) {
                // User's consent status failed to update.
            }
        });
        Log.e("tag", "Error");
    }

    // declare this function that will show the form
    protected void showConsentForm(){
        form.show();
    }

    private void consentForm() {
        URL privacyUrl = null;
        Log.e("tag", "7");
        try {
            // TODO: Replace with your app's privacy policy URL.
            privacyUrl = new URL("https://my-site.html");
        } catch (MalformedURLException e) {
            e.printStackTrace();
            // Handle error.
        }
        form = new ConsentForm.Builder(this, privacyUrl)
                .withListener(new ConsentFormListener() {
                    @Override
                    public void onConsentFormLoaded() {
                        // Consent form loaded successfully.
                        showConsentForm();
                    }

                    @Override
                    public void onConsentFormOpened() {
                        // Consent form was displayed.
                    }

                    @Override
                    public void onConsentFormClosed(
                            ConsentStatus consentStatus, Boolean userPrefersAdFree) {
                        // Consent form was closed.
                    }

                    @Override
                    public void onConsentFormError(String errorDescription) {
                        // Consent form error.
                        Log.e("tag", errorDescription);
                    }
                })
                .withPersonalizedAdsOption()
                .withNonPersonalizedAdsOption()
                .withAdFreeOption()
                .build();

        form.load();
    }

    private void initializeAds(boolean isPersonalized) {
        // initialize AdMob and configure your ad

        // this is the part you need to add/modify on your code
        AdRequest adRequest;
        if (isPersonalized) {
            adRequest = new AdRequest.Builder().build();
        } else {
            Bundle extras = new Bundle();
            extras.putString("npa", "1");
            adRequest = new AdRequest.Builder()
                    .addNetworkExtrasBundle(AdMobAdapter.class, extras)
                    .build();
        }

        // load the request into your adView

    }

Здесь также мой gradle файл, как вы можете видеть, я добавил необходимый код:

buildscript {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven {
            url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.31.0'  // Crashlytics plugin
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.6'
        classpath 'com.google.firebase:perf-plugin:1.3.1'  // Performance Monitoring plugin

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Я также добавил inte rnet разрешение на манифест, и я использую последнюю версию:

implementation 'com.google.android.ads.consent:consent-library:1.0.8'

Я также пытался использовать более старые версии, но все отображали одну и ту же ошибку

...