Rewarded Video

Integrate rewarded video ads

In general, rewarded videos are similar to fullscreen ads in the aspect that it covers the whole screen of the device. What rewarded video ads add is the ability to reward the user when he watches the videos.

Create Placement

To create an instance of RewardedVideoPlacement, use the following API:

RewardedVideoPlacement placement = AATKit.createRewardedVideoPlacement("<PLACEMENT_NAME>");

Listen to Callbacks (Optional)

Through the use of RewardedVideoPlacementListener, you can listen to the different placement callbacks.

placement.setListener(this);

AATKitReward

When the user is rewarded while watching a rewarded video, the placement will notify you through its delegate method: onUserEarnedIncentive passing itself and an AATKitReward instance.

Request Ad

You can load ads for the rewarded video placement either automatically or manually.

Automatic Reload

To automatically load rewarded video Placement:

placement.startAutoReload();

This way the rewarded video placement will always try to have an ad ready. Please also remember to stop the auto-reload when it is no longer needed:

placement.stopAutoReload();

The rewarded video placement fires the onHaveAd listener method only once per loaded ad. So, Before starting the auto-reload, you should check for ads from the previous load/auto-reload using the placement has ad API.

Manual Load

To manually load the rewarded video placement:

placement.reload();

Ad Info

After loading a rewarded video, you can access the loaded ad information by accessing the adInfo property of the fullscreen placement:

AdInfo adInfo = placement.getAdInfo();

Display Ad

the AATKit can be told to display a rewarded video placement using the following method:

placement.show();

The show() method will return a bool value indicating whether the rewarded video placement could be displayed or not. This means whether the rewarded video placement has a ready-rewarded video ad or not.

Has Ad

The rewarded video placement provides an API to check if it has a loaded ad.

boolean hasAd = placement.hasAd();

Complete Code Example

 private RewardedVideoPlacement placement = AATKit.createRewardedVideoPlacement("<PLACEMENT_NAME>");

@Override
protected void onResume() {
    super.onResume();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this);

    // Set placement listener to listen to the callbacks
    placement.setListener(this);
    // Start autoreloading the placement.
    placement.startAutoReload();
}

@Override
protected void onPause() {
    // [IMPORTANT] Stop placement autoreload
    placement.stopAutoReload();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityPause(this);
    super.onPause();
}

private void watchVideo() {
    // An example for showing the rewarded video ad when the user clicks on "watch Video" button.
    if (!placement.show()) {
        // Show a message to the user telling: "Currently, no video available. Please try again later."
    }
}

// RewardedVideoPlacementListener
@Override
public void onPauseForAd(@NonNull Placement placement) {
    // Ad has been displayed on the screen
}

@Override
public void onResumeAfterAd(@NonNull Placement placement) {
    // Back to the app
}

@Override
public void onHaveAd(@NonNull Placement placement) {
    // The placement has loaded a new ad
}

@Override
public void onNoAd(@NonNull Placement placement) {
    // The placement could not load a new ad
}

@Override
public void onUserEarnedIncentive(@NonNull Placement placement, @Nullable AATKitReward aatKitReward) {
    // The user has earned an incentive for this placement.
}

Last updated