Rewarded Ad
1. Basic requirements
Add ADX Android SDK to your project.
Use the Ad Unit ID issued for Rewarded Ad.
Before requesting an ad, SDK initialization must be done first.
SDK initialization should be called only once when the app launches and ad requests should be made after SDK initialization is complete.
2. Implementation
Instantiate the
RewardedAdand add theRewardedAdListener.Call
loadAd()to load the ad.After the ad is loaded and the
onAdLoaded()callback is received, either callshow()or checkisLoaded()to see if an ad is available, then callshow()to display the ad.When the ad is no longer needed, call the
destroy()method ofRewardedAdinonDestroy()to remove the ad.
public class RewardedAdActivity extends AppCompatActivity {
private com.adxcorp.ads.RewardedAd rewardedAd;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
rewardedAd = new RewardedAd(this, "<REWARDED_AD_UNIT_ID>");
rewardedAd.setRewardedAdListener(new RewardedAd.RewardedAdListener() {
@Override
public void onAdLoaded() {
}
@Override
public void onAdError(int errorCode) {
}
@Override
public void onAdClicked() {
}
@Override
public void onAdImpression() {
}
@Override
public void onAdClosed() {
}
@Override
public void onAdRewarded() {
}
@Override
public void onAdFailedToShow() {
}
});
rewardedAd.loadAd();
}
void show() {
if (rewardedAd != null && rewardedAd.isLoaded()) {
rewardedAd.show();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (rewardedAd != null) {
rewardedAd.destroy();
rewardedAd = null;
}
}
}3. Callback
Set the RewardedAd’s RewardedAdListener to receive specific events. Implement it as needed.
4. Ad Revenue (OnPaidEvent)
You can receive the estimated ad revenue while an ad impression occurs.
Manually set values during mediation setup and actual values may be mixed, so it is recommended to treat this as an estimate.
The currency unit of eCPM is USD.
As shown in the example below, use
OnPaidEventto check the estimated eCPM value.You can link ad revenue data with your MMP. For details, please refer to the SDK integration guides below:
5. SSV (Server-side verification) Settings
SSV settings are optional and can be configured only if needed.
SSV allows the reward event to trigger a server-to-server callback via the Callback URL.
The conditions for using SSV are as follows:
A
Rewarded Videotype with a registered Callback URL must be configured in the dashboard.A reward event must occur after the user has fully watched the video.
If necessary, set the
User IDorCustom Datainformation via the SDK before requesting an ad.
If the client sets the
User IDandCustom Data, they will be included in the Callback URL request.Example: https://callback_url?param=value&userid=<value>&customdata=<value>
SSV settings must be configured before the ad request to ensure the Callback URL includes the data.
Refer to the server-side SSV callback verification guide to verify the reward.
Last updated
Was this helpful?