-
Notifications
You must be signed in to change notification settings - Fork 3
Rewarded Ads
⚡ Before you start
Make sure you have correctly Initialize Ads.
Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards.
Call manual load ad before each show if Autoload Rewarded Ads
not checked.
In Blueprints you can use Load node just for register Loaded/Failed events.
UCASMobileAds::LoadRewardedAd();
![image](https://private-user-images.githubusercontent.com/22005013/299364448-f6c75b70-6af0-4308-a646-6be60ba7f096.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NzIyMjksIm5iZiI6MTcyMzg3MTkyOSwicGF0aCI6Ii8yMjAwNTAxMy8yOTkzNjQ0NDgtZjZjNzViNzAtNmFmMC00MzA4LWE2NDYtNmJlNjBiYTdmMDk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDA1MTg0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwZmFjMThkNjBjZWNjYTg5NGU4NThhMDY4ZWUyMWJkMWMxZGE5ODZjMDNjNmFmMzAzNDRkNzQ5NjA1MDcxZWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2zFQY-MbH06PM0wXwb-t9R1wUp6IsFRPKlFY-KNRH3s)
Note
The Event Once
checkbox will fire the Loaded/Failed event only once. if Autoload Ads
used, events can be triggered many times while the game world exists.
You can ask for the ad availability directly by calling the following function:
bool AdLoaded = UCASMobileAds::IsRewardedAdReady();
![image](https://private-user-images.githubusercontent.com/22005013/299364644-9489365c-b427-4975-abc5-2ad470c84e2a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NzIyMjksIm5iZiI6MTcyMzg3MTkyOSwicGF0aCI6Ii8yMjAwNTAxMy8yOTkzNjQ2NDQtOTQ4OTM2NWMtYjQyNy00OTc1LWFiYzUtMmFkNDcwYzg0ZTJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDA1MTg0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5YzNkYThjZWZmNjcxMTEwZjYyNGIxNDhlNzgxZGM3ZGI4ZjczNWQ4MTY0NjhiMjU0ZjA4OWNhNGM5MzZkOWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gc5FhxW_GPdoR7yWhGLW2-cy_S8fAsJNwBnaR9V2Bc0)
Important
We don’t recommend waiting for IsRewardedAdReady
to change each frame. This method call the native SDK and can affect the performance of your game.
Subscribe to the OnRewardedAdLoaded
event instead.
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: loading, opening, closing, and so on. Listen for these events by registering a delegate for the appropriate event, as shown below.
// Called when user earned reward.
UCASMobileAds::OnRewardedAdEarnedReward.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("User Earned reward"));
});
// Called when ad ready to shown.
UCASMobileAds::OnRewardedAdLoaded.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Rewarded loaded"));
});
// Called when ad failed to load with error.
UCASMobileAds::OnRewardedAdLoadFailed.AddLambda([=](ECASError Error){
UE_LOG(LogTemp, Log, TEXT("Rewarded failed to load: %s"),
UCASMobileAds::GetAdsErrorMessage(Error));
});
// Called when the ad shown.
UCASMobileAds::OnRewardedAdDisplayed.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Rewarded displayed"));
});
// Called when the ad is failed to display.
UCASMobileAds::OnRewardedAdShowFailed.AddLambda([=](ECASError Error){
UE_LOG(LogTemp, Log, TEXT("Rewarded failed to show: %s"),
UCASMobileAds::GetAdsErrorMessage(Error));
});
// Called when the user clicks on the Ad.
UCASMobileAds::OnRewardedAdClicked.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Rewarded clicked"));
});
// Called when the ad is closed.
UCASMobileAds::OnRewardedAdDismissed.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Rewarded dismissed"));
});
Note
Ad events in Blueprints are registered in the Load and Show nodes. Each new Load/Show Ad node cancels previous node events.
Before displaying a rewarded ad to users, you must present the user with an explicit choice to view rewarded ad content in exchange for a reward. Rewarded ads must always be an opt-in experience.
Subscribe to OnRewardedAdEarnedReward
event to reward the user.
UCASMobileAds::ShowRewardedAd();
![image](https://private-user-images.githubusercontent.com/22005013/299364828-f556d773-3a05-4d93-ae67-eb535efabc01.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NzIyMjksIm5iZiI6MTcyMzg3MTkyOSwicGF0aCI6Ii8yMjAwNTAxMy8yOTkzNjQ4MjgtZjU1NmQ3NzMtM2EwNS00ZDkzLWFlNjctZWI1MzVlZmFiYzAxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDA1MTg0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThiYjQ2ODNmZjRkNjk5ZGRhYzBiOTM3YTEzZTYzMzk4ZjU4ZTdlNDMyNmVmOTg5ZDM1MDY4ZTgzMjg2MmMzMzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZGQuJzOH3kM-IwO1-zAAH7b2LM4HkvshgyU3eOhb2TA)
Sounds in Rewarded and Rewarded ads mute state. Disabled by default.
UCASMobileAds::SetAdsMuted(Mute);
![image](https://private-user-images.githubusercontent.com/22005013/299362495-04b168b5-76f3-41cb-a3de-8f11de858d77.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4NzIyMjksIm5iZiI6MTcyMzg3MTkyOSwicGF0aCI6Ii8yMjAwNTAxMy8yOTkzNjI0OTUtMDRiMTY4YjUtNzZmMy00MWNiLWEzZGUtOGYxMWRlODU4ZDc3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDA1MTg0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTExMzZkNjdmZTdjODdjZTE2Njc1OTc0Y2E3ZDg3ZWI0NjVmMzNkYzhjMmZjMDQ3ZmFiNTI4YTc2YmQ3ODBhNDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.cypJT33bYqSNO9si5YJi-_WYsOog1mw4Nped-aqL-O4)
🔗 Done! What’s Next?
- Try another ad format:
- Read more about Impression level data.
- Project Setup
- Configuring SDK
- Include Android
- Include iOS
- Additional mediation steps
- FAQ
- App-ads.txt🔗