Documentation

Overview

Loading rewarded ads consists of several stages:

  1. Loading BidMachine RewardedRequest
  2. Setting up AdMob AdRequest by loaded BidMachine RewardedRequest
  3. Loading AdMob RewardedAd with configured AdMob AdRequest

Loading BidMachine RewardedRequest

Create a new RewardedRequest instance with AdRequestListener.
Execute request on the RewardedRequest 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 RewardedRequest instance
RewardedRequest rewardedRequest = new RewardedRequest.Builder()
        .setListener(new RewardedRequest.AdRequestListener() {
            @Override
            public void onRequestSuccess(@NonNull RewardedRequest rewardedRequest,
                                         @NonNull AuctionResult auctionResult) {
                runOnUiThread(() -> loadAdMobRewarded(rewardedRequest));
            }
        })
        .build();

// Request an ad from BidMachine without loading it
rewardedRequest.request(...);

Setting up AdMob AdRequest

Ways to set up AdMob AdRequest by BidMachine RewardedRequest:

  1. Create a new AdMob AdRequest instance
AdRequest adRequest = BidMachineUtils.createAdRequest(rewardedRequest);
  1. Create a new AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder =
    BidMachineUtils.createAdRequestBuilder(rewardedRequest);
AdRequest adRequest = adRequestBuilder.build();
  1. Fill an existing AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
BidMachineUtils.appendRequest(adRequestBuilder, rewardedRequest);
AdRequest adRequest = adRequestBuilder.build();

Loading AdMob RewardedAd

Use the AdMob AdRequest that was created during the previous step to load the AdMob RewardedAd

RewardedAd.load(..., ..., adRequest, ...);

📘

Sample App

You can find Sample App with BidMachineSDK and AdMob here: Github Rewarded