// UMyWidget.cpp (UMyWidget inherits from UObject to access TimerManager)
#include "Engine/World.h"
#include "TimerManager.h"
const FString RewardedAdUnitId = TEXT("«ad-unit-ID»");
FTimerHandle LoadTimerHandle;
void UMyWidget::InitializeRewardedAds()
// Bind member functions to delegates
UAppLovinMAX::OnRewardedAdLoadedDelegate.AddUObject(this, &UMyWidget::OnRewardedAdLoaded);
UAppLovinMAX::OnRewardedAdLoadFailedDelegate.AddUObject(this, &UMyWidget::OnRewardedAdLoadFailed);
UAppLovinMAX::OnRewardedAdDisplayFailedDelegate.AddUObject(this, &MyWidget::OnRewardedAdDisplayFailed);
UAppLovinMAX::OnRewardedAdHiddenDelegate.AddUObject(this, &UMyWidget::OnRewardedAdHidden);
UAppLovinMAX::OnRewardedAdReceivedRewardDelegate.AddUObject(this, &UMyWidget::OnRewardedAdReceivedReward);
// Load first rewarded ad
void UMyWidget::LoadRewardedAd()
UAppLovinMAX::LoadRewardedAd(RewardedAdUnitId);
void UMyWidget::OnRewardedAdLoaded(const FAdInfo &AdInfo)
// Rewarded ad is ready to be shown. UAppLovinMAX::IsRewardedAdReady(RewardedAdUnitId) will now return 'true'
void UMyWidget::OnRewardedAdLoadFailed(const FAdInfo &AdInfo, const FAdError &AdError)
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds)
AsyncTask(ENamedThreads::GameThread, [this]() {
float RetryDelay = FMath::Pow(2.0f, FMath::Min(6, RetryAttempt));
GetWorld()->GetTimerManager().SetTimer(LoadTimerHandle, this, &UMyWidget::LoadRewardedAd, RetryDelay, false);
void UMyWidget::OnRewardedAdDisplayFailed(const FAdInfo &AdInfo, const FAdError &AdError)
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
void UMyWidget::OnRewardedAdHidden(const FAdInfo &AdInfo)
// Rewarded ad is hidden. Pre-load the next ad.
void UMyWidget::OnRewardedAdReceivedReward(const FAdInfo &AdInfo, const FAdReward &Reward)
// Rewarded ad was displayed and user should receive the reward