App Open Ads
App open ads appear when users bring your game to the foreground.
Each ad format uses a Zone ID to identify the ad placement. Zone IDs are configured in the Empower dashboard.
Load the app open ad once the SDK is ready and show it when the user brings your game back to the foreground.
Loading an App Open Ad
Load the ad after OnSdkReady:
EmpowerAds.LoadAppOpenAd("YOUR_APP_OPEN_ZONE_ID");
Showing an App Open Ad
Show the ad when the game returns to the foreground, for example from Unity's OnApplicationPause callback:
EmpowerAds.ShowAppOpen("YOUR_APP_OPEN_ZONE_ID");
Listening to App Open Status
OnAppOpenStatusChanged reports these statuses:
| Status | Reported when |
|---|---|
Initializing | The load started |
Ready | Ad is loaded and ready to display |
Shown | Ad is being displayed |
Skipped | The user dismissed the ad |
Closed | The ad is closed |
WillLeave | User clicked the ad (leaving the game) |
Failed | The zone could not load an ad and has given up |
The example below shows the ad when the game resumes and loads the next ad on Closed:
using Empower.MobileAds;
using UnityEngine;
public class AppOpenController : MonoBehaviour
{
private const string ZoneId = "YOUR_APP_OPEN_ZONE_ID";
private bool _isReady;
void OnEnable()
{
EmpowerAds.OnAppOpenStatusChanged += HandleAppOpenStatus;
}
void OnDisable()
{
EmpowerAds.OnAppOpenStatusChanged -= HandleAppOpenStatus;
}
// Call after OnSdkReady.
public void Load()
{
EmpowerAds.LoadAppOpenAd(ZoneId);
}
void OnApplicationPause(bool paused)
{
if (!paused && _isReady)
EmpowerAds.ShowAppOpen(ZoneId);
}
private void HandleAppOpenStatus(AdStatus status, string zoneId)
{
if (zoneId != ZoneId) return;
switch (status)
{
case AdStatus.Ready:
_isReady = true;
break;
case AdStatus.Shown:
case AdStatus.Failed:
_isReady = false;
break;
case AdStatus.Closed:
_isReady = false;
EmpowerAds.LoadAppOpenAd(ZoneId);
break;
}
}
}
Do not show an app open ad on every return to the game. Show it only after the game spent a meaningful time in the background.
On Android Closed always follows Skipped, so loading the next ad on Closed is enough. On iOS Closed may not follow, so handle Skipped there as well.