最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

android - Some ad requests on your inventory from the EEA, the UK, or Switzerland are missing a TC string, admob error - Stack O

matteradmin8PV0评论

I've implemented CMP "a certified consent management platform (CMP)".according to admob request, I followed google implementation here: But I am still getting error from admob console "Some ad requests on your inventory from the EEA, the UK, or Switzerland are missing a TC string"

Main activity code as below:

        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();
    }

Anny suggestion?

I've implemented CMP "a certified consent management platform (CMP)".according to admob request, I followed google implementation here: But I am still getting error from admob console "Some ad requests on your inventory from the EEA, the UK, or Switzerland are missing a TC string"

Main activity code as below:

        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();
    }

Anny suggestion?

Share Improve this question asked Nov 18, 2024 at 14:05 صلي علي محمد - Atef Faroukصلي علي محمد - Atef Farouk 4,2972 gold badges37 silver badges56 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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;
}

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far