App Open Ads - cleveradssolutions/CAS-Unreal GitHub Wiki
App open ads are a special ad format intended for publishers wishing to monetize their app load screens. App open ads can be closed at any time, and are designed to be shown when your users bring your app to the foreground.
App open ads automatically show a small branding area so users know they're in your app.
This guide explains how to integrate app open ads into an Unreal Engine project.
flowchart TD
A[Autoload] -->|auto| L((Load))
L -->|success| R([OnAdLoaded])
L -->|fail| F([OnAdLoadFailed])
F -->|delay| A
R --> RL[IsAdReady]
S((Show)) --> RL
RL -->|success| SR([OnAdDisplayed])
RL -->|fail| SF([OnAdShowFailed])
SR --> I([OnAdsImpression])
SR --> C([OnAdClicked])
I --> D([OnAdDismissed])
D --> A
SF --> A
Load an Ad
Call manual load ad before each show if Autoload App Open Ads
not checked.
In Blueprints you can use Load node just for register Loaded/Failed events.
UCASMobileAds::LoadAppOpenAd();
[!NOTE]
TheEvent Once
checkbox will fire the Loaded/Failed event only once. ifAutoload Ads
used, events can be triggered many times while the game world exists.
Autoload mode
If enabled, the ad will automatically load new content when the current ad is dismissed or completed. Additionally, it will automatically retry loading the ad if an error occurs during the loading process.
UCASMobileAds::SetAutoloadAppOpenAd(true);
You should call LoadAppOpenAd()
once to create Ad Instance.
By default, autoloading is defined in the Project Settings -> Plugins -> CAS.AI Config -> Autoload App Open Ads
.
Ad events
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 ad ready to shown.
UCASMobileAds::OnAppOpenAdLoaded.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("AppOpen loaded"));
});
// Called when ad failed to load with error.
UCASMobileAds::OnAppOpenAdLoadFailed.AddLambda([=](ECASError Error){
UE_LOG(LogTemp, Log, TEXT("AppOpen failed to load: %s"),
UCASMobileAds::GetAdsErrorMessage(Error));
});
// Called when the ad shown.
UCASMobileAds::OnAppOpenAdDisplayed.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("AppOpen displayed"));
});
// Called when the ad is failed to display.
UCASMobileAds::OnAppOpenAdShowFailed.AddLambda([=](ECASError Error){
UE_LOG(LogTemp, Log, TEXT("AppOpen failed to show: %s"),
UCASMobileAds::GetAdsErrorMessage(Error));
});
// Called when the user clicks on the Ad.
UCASMobileAds::OnAppOpenAdClicked.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("AppOpen clicked"));
});
// Called when the ad is closed.
UCASMobileAds::OnAppOpenAdDismissed.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("AppOpen dismissed"));
});
[!NOTE]
Ad events in Blueprints are registered in the Load and Show nodes. Each new Load/Show Ad node cancels previous node events.
Show the Ad
To display the ad, call the following method:
UCASMobileAds::ShowAppOpenAd();
Autoshow mode
Use the AutoshowAppOpenAd
method to automatically show the loaded ad when the user returns to the app.
UCASMobileAds::AutoshowAppOpenAd();
Use the DisableAutoshowInterstitialAd
method to disable automatically show the ad.
UCASMobileAds::DisableAutoshowAppOpenAd();
Release ad resource
Destroys the ad content and releases any associated resources when the ad is no longer needed to clean up resources and prevent memory leaks.
UCASMobileAds::DestroyAppOpenAd();
Call LoadAppOpenAd
to load new ad and restore autoload mode if used.
Ad Availability
You can ask for the ad availability directly by calling the following function:
bool AdLoaded = UCASMobileAds::IsAppOpenAdReady();
[!IMPORTANT]
We don’t recommend waiting forIsAppOpenAdReady
to change each frame. This method call the native SDK and can affect the performance of your game.
Subscribe to theOnAppOpenAdLoaded
event instead.
Muted Ads Sounds
Sounds in Interstitial and Rewarded ads mute state. Disabled by default.
UCASMobileAds::SetAdsMuted(Mute);
🔗 Done! What’s Next?
- Try another ad format:
- Read more about Impression level data.