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.
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();
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();
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();
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();
val info = placement.adInfo
Display Ad
the AATKit can be told to display a rewarded video placement using the following method:
placement.show();
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();
val hasAd = placement.hasAd()
Complete Code Example
privateRewardedVideoPlacement placement =AATKit.createRewardedVideoPlacement("<PLACEMENT_NAME>");@OverrideprotectedvoidonResume() { super.onResume();// [IMPORTANT] Notify AATKit about activity lifecycleAATKit.onActivityResume(this);// Set placement listener to listen to the callbacksplacement.setListener(this);// Start autoreloading the placement.placement.startAutoReload();}@OverrideprotectedvoidonPause() {// [IMPORTANT] Stop placement autoreloadplacement.stopAutoReload();// [IMPORTANT] Notify AATKit about activity lifecycleAATKit.onActivityPause(this); super.onPause();}privatevoidwatchVideo() {// 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@OverridepublicvoidonPauseForAd(@NonNullPlacement placement) {// Ad has been displayed on the screen}@OverridepublicvoidonResumeAfterAd(@NonNullPlacement placement) {// Back to the app}@OverridepublicvoidonHaveAd(@NonNullPlacement placement) {// The placement has loaded a new ad}@OverridepublicvoidonNoAd(@NonNullPlacement placement) {// The placement could not load a new ad}@OverridepublicvoidonUserEarnedIncentive(@NonNullPlacement placement, @NullableAATKitReward aatKitReward) {// The user has earned an incentive for this placement.}
privateval placement =createRewardedVideoPlacement("<PLACEMENT_NAME>")overridefunonResume() {super.onResume()// [IMPORTANT] Notify AATKit about activity lifecycle AATKit.onActivityResume(this)// Set placement listener to listen to the callbacks placement?.listener =this// Start autoreloading the placement. placement?.startAutoReload()}overridefunonPause() {// [IMPORTANT] Stop placement autoreload placement?.stopAutoReload()// [IMPORTANT] Notify AATKit about activity lifecycle AATKit.onActivityPause(this)super.onPause()}privatefunwatchVideo() {// An example for showing the rewarded video ad when the user clicks on "watch Video" button.if (placement?.show() ==false) {// Show a message to the user telling: "Currently, no video available. Please try again later." }}// RewardedVideoPlacementListeneroverridefunonPauseForAd(placement: Placement) {// Ad has been displayed on the screen}overridefunonResumeAfterAd(placement: Placement) {// Back to the app}overridefunonHaveAd(placement: Placement) {// The placement has loaded a new ad}overridefunonNoAd(placement: Placement) {// The placement could not load a new ad}overridefunonUserEarnedIncentive(placement: Placement, aatKitReward: AATKitReward?) {// The user has earned an incentive for this placement.}