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);
bool isLoaded = (await AdxSdk.isRewardedAdLoaded(adUnitId))!;
if (isLoaded) {
AdxSdk.showRewardedAd(adUnitId);(adUnitId);
}
@override
void dispose() {
super.dispose();
AdxSdk.destroyRewardedAd(adUnitId);
}
특정 이벤트를 수신할 수 있습니다. 필요에 따라 구현해주세요.
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
});
}