public static showRewardedAd(callback: () => void) {
ads2_script.rewardVideoCallback = callback;
console.log(“callbackfunction”,ads2_script.rewardVideoCallback)
if (ads2_script.rewardedAdClient) {
ads2_script.rewardedAdClient.show();
} else {
console.log(“Rewarded ad is not loaded yet”);
ads2_script.rewardedAdClient.load(TestUnitId.RewardedAd, {
onAdLoaded: () => {
console.log(“Rewarded ad loaded successfully”);
ads2_script.rewardedAdClient.show();
},
onAdFailedToLoad: (loadAdError) => {
console.log(“Failed to load rewarded ad”, loadAdError);
ads2_script.rewardedAdClient.destroy();
},
onEarn: (rewardType, amount) => {
console.log(Reward earned: type = ${rewardType}, amount = ${amount}
);
if (ads2_script.rewardVideoCallback) {
ads2_script.rewardVideoCallback();
}
},
onAdDismissedFullScreenContent: () => {
console.log("Rewarded ad dismissed");
},
onAdFailedToShowFullScreenContent: (adError) => {
console.log("Failed to show rewarded ad", adError);
ads2_script.rewardedAdClient.destroy();
},
onPaidEvent: (paidNTF) => {
console.log("Ad generated revenue", paidNTF);
},
});
}
}