Rewarded Ad
1. Basic Requirements
Add ADX Flutter SDK to your project.
Use the ADX Ad Unit ID issued for Reward 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
If the app is distributed on both Android and iOS, enter the Ad Unit ID issued for each platform.
Register the necessary callbacks.
Call
AdxSdk.loadRewardedAd()
to load the ad.Call
AdxSdk.destroyRewardedAd()
when disposing of the ad object.
String adUnitId = Platform.isAndroid ? "<ANDROID_ADX_REWARDED_AD_UNIT_ID>" : "<IOS_ADX_REWARDED_AD_UNIT_ID>";
AdxSdk.setRewardedAdListener(RewardedAdListener(
onAdLoaded: (){
},
onAdError: (int errorCode){
},
onAdImpression: (){
},
onAdClicked: (){
},
onAdRewarded: (){
},
onAdClosed: (){
},
onAdFailedToShow: (){
})
);
AdxSdk.loadRewardedAd(adUnitId);
Once the ad is loaded, call
showRewardedAd()
to display the ad.
bool isLoaded = (await AdxSdk.isRewardedAdLoaded(adUnitId))!;
if (isLoaded) {
AdxSdk.showRewardedAd(adUnitId);
}
static void showRewardedAd(String adUnitId, {
String? ssvUserId,
String? ssvCustomData
})
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 Video
type 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 ID
orCustom Data
information via the SDK before requesting an ad.If the client sets the
User ID
andCustom 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.
Supported in Flutter ADX Plugin version 1.0.6 or later.
Refer to the server-side SSV callback verification guide to verify the reward.
Call
destroyRewardedAd()
when disposing of the ad object.
@override
void dispose() {
super.dispose();
AdxSdk.destroyRewardedAd(adUnitId);
}
3. Callback
You can receive specific events. Implement as needed.
class RewardedAdListener {
void Function() onAdLoaded;
void Function(int errorCode) onAdError;
void Function() onAdImpression;
void Function() onAdClicked;
void Function() onAdRewarded;
void Function() onAdClosed;
void Function() onAdFailedToShow;
RewardedAdListener({
required this.onAdLoaded,
required this.onAdError,
required this.onAdImpression,
required this.onAdClicked,
required this.onAdRewarded,
required this.onAdClosed,
required this.onAdFailedToShow
});
}
Last updated
Was this helpful?