Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we first call MobileAds.setRequestConfiguration or MobileAds.initialize?

Tags:

android

admob

There isn't much documentation on this. I was wondering, should we first call

RequestConfiguration conf= new RequestConfiguration.Builder()
        .setMaxAdContentRating(
                MAX_AD_CONTENT_RATING_T)
        .build();

MobileAds.setRequestConfiguration(conf);
MobileAds.initialize(context, APP_ID);

Or

MobileAds.initialize(context, APP_ID);
RequestConfiguration conf= new RequestConfiguration.Builder()
        .setMaxAdContentRating(
                MAX_AD_CONTENT_RATING_T)
        .build();

MobileAds.setRequestConfiguration(conf);

In https://developers.google.com/admob/android/quick-start

Although Google recommend calling MobileAds.initialize as early as possible

Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() which initializes the SDK and calls back a completion listener once initialization is complete (or after a 30-second timeout). This needs to be done only once, ideally at app launch.

They also mention "request-specific flags" need to be set before MobileAds.initialize.

Warning: Ads may be preloaded by the Mobile Ads SDK or mediation partner SDKs upon calling MobileAds.initialize(). If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags (such as tagForChildDirectedTreatment or tag_for_under_age_of_consent), or otherwise take action before loading ads, ensure you do so before initializing the Mobile Ads SDK.

So, not super clear on which should be called first.

like image 833
Cheok Yan Cheng Avatar asked Sep 24 '19 16:09

Cheok Yan Cheng


1 Answers

According to Google Developer support, the following is the right way to do

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/17oVu0sABjs

RequestConfiguration conf= new RequestConfiguration.Builder()
        .setMaxAdContentRating(
                MAX_AD_CONTENT_RATING_T)
        .build();

MobileAds.setRequestConfiguration(conf);
MobileAds.initialize(context, APP_ID);
like image 128
Cheok Yan Cheng Avatar answered Oct 24 '22 23:10

Cheok Yan Cheng