callAds method
void
callAds({
- required String adId,
- String action = "default",
- required AdCallerInterface adCallerInterface,
Implementation
void callAds({
required String adId,
String action = "default",
required AdCallerInterface adCallerInterface,
}) {
RewardedInterstitialAd.load(
adUnitId: adId,
request: const AdRequest(),
rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
onAdLoaded: (ad) {
AdLogger.logAd(action: action,provider: googleRewardAdKey, status: adLoadedKey);
_rewardNormalAd = ad;
_rewardNormalAd!.fullScreenContentCallback =
FullScreenContentCallback(
onAdShowedFullScreenContent: (RewardedInterstitialAd ad) {},
onAdDismissedFullScreenContent: (RewardedInterstitialAd ad) {
AdLogger.logAd(
action: action,
provider: googleRewardAdKey, status: adDismissedKey);
if (adCallerInterface.onRewardSkip != null) {
adCallerInterface.onRewardSkip!();
}
},
onAdFailedToShowFullScreenContent:
(RewardedInterstitialAd ad, AdError error) {
AdLogger.logAd(action: action,provider: googleRewardAdKey, status: adFailedKey);
adCallerInterface.onError();
ad.dispose();
},
);
adCallerInterface.onLoaded();
_rewardNormalAd!.show(
onUserEarnedReward: (AdWithoutView ad, RewardItem rewardItem) {
adCallerInterface.onClose();
ad.dispose();
});
},
onAdFailedToLoad: (error) {
_rewardNormalAd = null;
AdLogger.logAd(
action: action,
provider: googleRewardAdKey, status: adFailedToLoadKey);
adCallerInterface.onError();
},
),
);
}