ADMOB GDPR测试弹出但不显示是或否

时间:2018-06-04 16:18:21

标签: android android-studio popup admob

enter image description here

我关注文档admob sdk,但是当我用vpn欧洲测试应用程序时,我弹出的不像弹出文档中没有显示是或否或付费广告

  • Google移动广告SDK的默认行为是提供个性化广告。如果用户同意仅接收非个性化广告,您可以使用以下代码配置AdRequest对象,以指定只返回非个性化广告:

这是我的代码:

    ConsentInformation consentInformation = ConsentInformation.getInstance(getApplicationContext());
    String[] publisherIds = {""};
    consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
        @Override
        public void onConsentInfoUpdated(ConsentStatus consentStatus) {
            // User's consent status successfully updated.
            boolean inEEA = ConsentInformation.getInstance(getApplicationContext()).isRequestLocationInEeaOrUnknown();

      if(inEEA){

          Toast.makeText(Splash.this,consentStatus.toString(),Toast.LENGTH_SHORT).show();
                if (consentStatus==consentStatus.PERSONALIZED ||consentStatus==consentStatus.NON_PERSONALIZED )
                {
                    Bundle extras = new Bundle();
                    extras.putString("npa", "1");


                    AdRequest request = new AdRequest.Builder()
                            .addNetworkExtrasBundle(AdMobAdapter.class, extras)
                            .build();


                }else {

                    URL privacyUrl = null;
                    try {
                        // TODO: Replace with your app's privacy policy URL.
                        privacyUrl = new URL("");
                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                        // Handle error.
                    }
                     form = new ConsentForm.Builder(Splash.this, privacyUrl)
                            .withListener(new ConsentFormListener() {
                                @Override
                                public void onConsentFormLoaded() {
                                    // Consent form loaded successfully.
                                    form.show();
                                }

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

                                @Override
                                public void onConsentFormClosed(
                                        ConsentStatus consentStatus, Boolean userPrefersAdFree) {
                                    // Consent form was closed.
                                    Bundle extras = new Bundle();
                                    extras.putString("npa", "1");

                                    AdRequest request = new AdRequest.Builder()
                                            .addNetworkExtrasBundle(AdMobAdapter.class, extras)
                                            .build();
                                }

                                @Override
                                public void onConsentFormError(String errorDescription) {
                                    // Consent form error.
                                }
                            })
                            .withPersonalizedAdsOption()
                            .withNonPersonalizedAdsOption()
                            .withAdFreeOption()
                            .build();
                    form.load();
                }
             }else {

    }
        }

        @Override
        public void onFailedToUpdateConsentInfo(String errorDescription) {
            // User's consent status failed to update.
        }
    });

0 个答案:

没有答案