-
Notifications
You must be signed in to change notification settings - Fork 4
Rewarded Ads
⚡ Before you start
Make sure you have correctly Initialize CAS.
This guide explains how to integrate rewarded video ads into an Android app.
Note
By default, the auto-load ads mode is used and a load method does not need to be called.
Call manual load ad before each show if you use LoadingManagerMode.Manual
only.
Manual load Rewarded ads.
manager.loadRewardedAd();
You can get a callback for the successful loading of the ads:
manager.getOnAdLoadEvent().add(new AdLoadCallback() {
@Override
public void onAdLoaded(@NonNull AdType type) {
if (type == AdType.Rewarded) {
// Rewarded loaded
}
}
@Override
public void onAdFailedToLoad(@NonNull AdType type, @Nullable String error) {
if (type == AdType.Rewarded) {
// Rewaeded failed to load with error
}
}
});
You can ask for the ad availability directly by calling the following function:
boolean adLoaded = manager.isRewardedAdReady();
The AdCallback
handles events related to displaying your Rewarded ad.
AdCallback callback = new AdCallback() {
@Override
public void onShown(@NonNull AdStatusHandler ad) {
// Called when ad is shown.
}
@Override
public void onShowFailed(@NonNull String message) {
// Called when ad fails to show.
}
@Override
public void onClicked() {
// Called when a click is recorded for an ad.
}
@Override
public void onComplete() {
// Called when ad is completed
Log.d("Sample", "The user earned the reward.");
}
@Override
public void onClosed() {
// Called when ad is dismissed
}
};
Warning
When an error occurs during ad impression, executed the onShowFailed()
only.
onClosed()
in this case will not be executed, since the impression is not considered successful.
Note
Read more about event onShown
with Impression level data.
Before displaying a rewarded ad to users, you must present the user with an explicit choice to view rewarded ad content in exchange for a reward. Rewarded ads must always be an opt-in experience.
The showRewardedAd()
method requires Activity
and AdCallback
instances as arguments.
-
activity
The Activity instance should be the activity from which the rewarded ad is presented. -
callback
The callback for Rewarded ad events.
When you show a rewarded ad, you will use anAdCallback
object to handle reward eventsonComplete()
.
manager.showRewardedAd(activity, callback);
Sometimes a situation occurs when filling Rewarded ads is not enough, in this case, you can allow the display of Interstitial ads to receiving a reward in any case. This option will compare ad cost and serve regular interstitial ads when rewarded video ads are expected to generate less revenue.
Interstitial Ads does not require to watch the video to the end, but the AdCallback.onComplete()
event will be invoked in any case.
Enabled by default.
CAS.getSettings().setAllowInterstitialAdsWhenVideoCostAreLower(true);
Indicates if the application’s audio is muted. Affects initial mute state for all ads.
Use this method only if your application has its own volume controls.
CAS.getSettings().setMutedAdSounds(true);
🔗 Done! What’s Next?
- Try another ad format:
- Read more about Impression level data.
- Project Setup
- Advanced integration
- Additional mediation steps
- Link the project
- App-ads.txt🔗