首页 > 解决方案 > 使用 ump / admob / 资金选择获得同意的问题

问题描述

按照本指南https://developers.google.com/admob/ump/android/quick-start我尝试将所有内容添加到我的应用程序中。

我做了什么:

然后我将此代码添加到我的应用程序中

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

        consentInformation = UserMessagingPlatform.getConsentInformation(this);
        consentInformation.requestConsentInfoUpdate(
                this,
                params,
                new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
                    @Override
                    public void onConsentInfoUpdateSuccess() {
                        // The consent information state was updated.
                        // You are now ready to check if a form is available.
                        if (consentInformation.isConsentFormAvailable()) {
                            loadForm();
                        }
                        else {

                        Context context = getApplicationContext();

                        CharSequence toastText = "No Form Available";

                        int duration = Toast.LENGTH_LONG;

                        Toast toast = Toast.makeText(context, toastText, duration);
                        toast.show();
                        }

                        
                    }

                },
                new ConsentInformation.OnConsentInfoUpdateFailureListener() {
                    @Override
                    public void onConsentInfoUpdateFailure(FormError formError) {
                        // Handle the error.
                        
                        Context context = getApplicationContext();

                        CharSequence toastText = "Error";

                        int duration = Toast.LENGTH_LONG;

                        Toast toast = Toast.makeText(context, toastText, duration);
                        toast.show();

                    }
                });

public void loadForm() {
        UserMessagingPlatform.loadConsentForm(
                this,
                new UserMessagingPlatform.OnConsentFormLoadSuccessListener() {
                    @Override
                    public void onConsentFormLoadSuccess(ConsentForm consentForm) {
                        MainActivity.this.consentForm = consentForm;
                        if(consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
                            consentForm.show(
                                    MainActivity.this,
                                    new ConsentForm.OnConsentFormDismissedListener() {
                                        @Override
                                        public void onConsentFormDismissed(@Nullable FormError formError) {
                                            // Handle dismissal by reloading form.
                                            loadForm();
                                        }
                                    });

                        }
                    }
                },
                new UserMessagingPlatform.OnConsentFormLoadFailureListener() {
                    @Override
                    public void onConsentFormLoadFailure(FormError formError) {
                        // Handle the error
                    }
                }
        );
    }

但是,我总是在 onConsentInfoUpdateFailure(FormError formError) 独立于我的手机或虚拟设备上的测试(我在欧洲顺便说一句)中获得吐司“错误”。

我错过了什么吗?

谢谢, 塞尔德里

标签: javaandroidgdprconsentform

解决方案


我遇到了同样的问题,我只是通过正确配置我的 adMob 帐户来解决它。


推荐阅读