来自欧洲经济区、英国或瑞士的针对您的广告资源的某些广告请求缺少 TC 字符串,即 admob 错误

问题描述 投票:0回答:1

我已经实施了 CMP“经过认证的同意管理平台 (CMP)”。根据 admob 请求,我遵循了 google 实施此处:但我仍然从 admob 控制台收到错误“来自 EEA 的库存上的一些广告请求,英国或瑞士缺少 TC 字符串”

主要活动代码如下:

        googleMobileAdsConsentManager =
            GoogleMobileAdsConsentManager.getInstance(getApplicationContext());
    googleMobileAdsConsentManager.gatherConsent(
            this,
            consentError -> {
                if (consentError != null) {
                    // Consent not obtained in current session.
                   
                }
               

                if (googleMobileAdsConsentManager.canRequestAds()) {
                    initializeMobileAdsSdk();
                }

                if (googleMobileAdsConsentManager.isPrivacyOptionsRequired()) {
                    // Regenerate the options menu to include a privacy setting.
                    invalidateOptionsMenu();
                }
            });

    // This sample attempts to load ads using consent obtained in the previous session.
    if (googleMobileAdsConsentManager.canRequestAds()) {
        initializeMobileAdsSdk();
    }

有什么建议吗?

android admob gdprconsentform ump
1个回答
0
投票
    After user grants or declines the Ads Personalisation request a key is stored in Shared preferences Automatically. 
    Shared preference Key name :- IABTCF_TCString

    String tcString;
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    tcString = sp.getString("IABTCF_TCString", "Key not found");


Pass in AdMob 

  

     AdRequest adRequest = new AdRequest.Builder()
                    .addNetworkExtrasBundle(NativeAd.class, createAdMobExtras(tcString))  // Passing TC string
                    .build();

private Bundle createAdMobExtras(String tcString) {
    Bundle extras = new Bundle();
    extras.putString("tcString", tcString);  // Pass the TC string using the correct key
    return extras;
}
© www.soinside.com 2019 - 2024. All rights reserved.