Banner
Waterfall
Integration remains consistent with the approach outlined in Google AdMob, ensuring seamless compatibility with existing configurations. No further modifications are necessary, streamlining the implementation process and minimizing any additional overhead.
Prebid
Overview
Loading banner ads consists of several stages:
- Loading BidMachine BannerRequest
- Setting up AdMob AdRequest by loaded BidMachine BannerRequest
- Loading AdMob AdView with configured AdMob AdRequest
Auto-Refresh
Auto-refresh is not supported. For this type of integration, all of the above steps must be repeated.
Loading BidMachine BannerRequest
Create a new BannerRequest instance with a specific BannerSize and AdRequestListener.
Execute request
on the BannerRequest instance to start loading.
When the onRequestSuccess
callback is triggered, it means that the request has been successfully loaded and you can proceed to AdMob AdRequest settings.
// Create new BidMachine BannerRequest instance
BannerRequest bannerRequest = BidMachineAdRequestBuilderFactory.createBannerRequestBuilder()
.setSize(...)
.setListener(new BannerRequest.AdRequestListener() {
@Override
public void onRequestSuccess(@NonNull BannerRequest bannerRequest,
@NonNull AuctionResult auctionResult) {
runOnUiThread(() -> loadAdMobBanner(bannerRequest));
}
})
.build();
// Request an ad from BidMachine without loading it
bannerRequest.request(...);
// Create new BidMachine request
val bannerRequest = BidMachineAdRequestBuilderFactory.createBannerRequestBuilder()
.setSize(...)
.setListener(object : BannerRequest.AdRequestListener {
override fun onRequestSuccess(bannerRequest: BannerRequest, auctionResult: AuctionResult) {
runOnUiThread { loadAdMobBanner(bannerRequest) }
}
})
.build().also {
// Request an ad from BidMachine without loading it
it.request(context)
}
Setting up AdMob AdRequest
Ways to set up AdMob AdRequest by BidMachine BannerRequest:
- Create a new AdMob AdRequest instance
AdRequest adRequest = BidMachineUtils.createAdRequest(bannerRequest);
val adRequest = BidMachineUtils.createAdRequest(bannerRequest)
- Create a new AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder = BidMachineUtils.createAdRequestBuilder(bannerRequest);
AdRequest adRequest = adRequestBuilder.build();
val adRequestBuilder = BidMachineUtils.createAdRequestBuilder(bannerRequest)
val adRequest = adRequestBuilder.build()
- Fill an existing AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
BidMachineUtils.appendRequest(adRequestBuilder, bannerRequest);
AdRequest adRequest = adRequestBuilder.build();
val adRequestBuilder = AdRequest.Builder()
BidMachineUtils.appendRequest(adRequestBuilder, bannerRequest)
val adRequest = adRequestBuilder.build()
Loading AdMob AdView
Use the AdMob AdRequest that was created during the previous step to load the AdMob AdView
// Create new AdView instance
AdView adView = new AdView(...);
adView.setLayoutParams(...);
adView.setAdUnitId(...);
adView.setAdSize(AdSize.BANNER);
adView.setAdListener(...);
// Load AdView with AdMob AdRequest
adView.loadAd(adRequest);
// Create new AdView instance
val adView = AdView(...)
adView.setLayoutParams(...)
adView.setAdUnitId(...)
adView.setAdSize(AdSize.BANNER)
adView.setAdListener(...)
// Load AdView with AdMob AdRequest
adView.loadAd(adRequest)
Sample App
You can find Sample App with BidMachineSDK and AdMob here: Github Banner
Updated 12 days ago