Only show admob ads. waiting for 2 days. I set priority to FAN but no any Facebook audience network ad requests. Need additional code for native ads request?
private void loadNativeAds() {
mNativeAds = new ArrayList<>();
AdLoader.Builder builder = new AdLoader.Builder(MainActivity.this, getString(R.string.ad_unit_id));
adLoader = builder.forUnifiedNativeAd(
new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
@Override
public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
// A native ad loaded successfully, check if the ad loader has finished loading
// and if so, insert the ads into the list.
mNativeAds.add(unifiedNativeAd);
if (!adLoader.isLoading()) {
insertAdsInMenuItems();
}
}
}).withAdListener(
new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
// A native ad failed to load, check if the ad loader has finished loading
// and if so, insert the ads into the list.
if (!adLoader.isLoading()) {
insertAdsInMenuItems();
}
}
}).build();
// Load the Native ads.
adLoader.loadAds(new AdRequest.Builder().build(), NUMBER_OF_ADS);
}
As per the documentation here ,
The
loadAds()
method currently works only with AdMob ads. For mediated ads, useloadAd()
instead.
Changing adLoader.loadAds()
to adLoader.loadAd()
should start loading Facebook Audience Network native ads.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.