App Open Ads
App open ad units appear when the user opens your app or switches back to your app. App open ad units appear on the loading or splash screen.
Benefits of App Open Ads
- An ad overlays the loading screen
- The unique app open ad layout offers the best user experience for this placement.
- Unlock new inventory: monetize users as soon as they open your app.
- Maximize demands
- Highest bidding ad creatives
- Availability of both full-screen and partial-screen ads
- Optimized user experience rendering
You should finish these steps before releasing.
Load the ad
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
Yodo1U3dAppOpenAd.GetInstance().LoadAd();
Yodo1MasAppOpenAd.getInstance().loadAd(MainActivity.this);
Yodo1MasAppOpenAd.getInstance().loadAd(this@MainActivity)
Yodo1MasAppOpenAd.sharedInstance().load()
[[Yodo1MasAppOpenAd sharedInstance] loadAd];
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
// Remember to call this function before SDK init.
Yodo1U3dAppOpenAd.GetInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasAppOpenAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasAppOpenAd.getInstance().autoDelayIfLoadFail = true
// Remember to call this function before SDK init.
Yodo1MasAppOpenAd.sharedInstance().autoDelayIfLoadFail = true
// Remember to call this function before SDK init.
[Yodo1MasAppOpenAd sharedInstance].autoDelayIfLoadFail = YES;
No need to configure on Godot
Display the ad
You can show the ad using this code, but we recommend using the ad events as you’ll be able to show the ad once it’s loaded. You can check the full script provided below.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
bool isLoaded = Yodo1U3dAppOpenAd.GetInstance().IsLoaded();
// Show ad without placement name
if (isLoaded)
{
Yodo1U3dAppOpenAd.GetInstance().ShowAd();
}
// Show ad with placement name, like app_start, level_end
if (isLoaded)
{
Yodo1U3dAppOpenAd.GetInstance().ShowAd("Your placement id");
}
boolean isLoaded = Yodo1MasAppOpenAd.getInstance().isLoaded();
// Show ad without placement name
if (isLoaded) Yodo1MasAppOpenAd.getInstance().showAd(this);
// Show ad with placement name, like app_start, level_end
if (isLoaded) Yodo1MasAppOpenAd.getInstance().showAd(this, "Your placement id");
val isLoaded = Yodo1MasAppOpenAd.getInstance().isLoaded();
// Show ad without placement name
if (isLoaded) Yodo1MasAppOpenAd.getInstance().showAd(this@MainActivity)
// Show ad with placement name, like app_start, level_end
if (isLoaded) Yodo1MasAppOpenAd.getInstance().showAd(this@MainActivity, "Your placement id")
let isLoaded = Yodo1MasAppOpenAd.sharedInstance().isLoaded()
// Show ad without placement name
if isLoaded { Yodo1MasAppOpenAd.sharedInstance().show() }
// Show ad with placement name, like app_start, level_end
if isLoaded { Yodo1MasAppOpenAd.sharedInstance().show(withPlacement: "Your placement id") }
BOOL isLoaded = [[Yodo1MasAppOpenAd sharedInstance] isLoaded];
// Show ad without placement name
if (isLoaded) [[Yodo1MasAppOpenAd sharedInstance] showAd];
// Show ad with placement name, like app_start, level_end
if (isLoaded) [[Yodo1MasAppOpenAd sharedInstance] showAdWithPlacement:@"Your placement id"];
// App open ads are displayed automatically
Configure the ad events
The MAS SDK fires several events to inform you of ad availability.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
using Yodo1.MAS;
using System;
public class AppOpenAdLoader : MonoBehaviour
{
private int retryAttempt = 0;
private void Start()
{
SetupEventCallbacks();
LoadAppOpenAd();
}
private void SetupEventCallbacks()
{
Yodo1U3dAppOpenAd.GetInstance().OnAdLoadedEvent += OnAppOpenAdLoadedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdLoadFailedEvent += OnAppOpenAdLoadFailedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdOpenedEvent += OnAppOpenAdOpenedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdOpenFailedEvent += OnAppOpenAdOpenFailedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdClosedEvent += OnAppOpenAdClosedEvent;
}
private void LoadAppOpenAd()
{
Yodo1U3dAppOpenAd.GetInstance().SetAdPlacement("Your placement id");
Yodo1U3dAppOpenAd.GetInstance().LoadAd();
}
private void OnAppOpenAdLoadedEvent(Yodo1U3dAppOpenAd ad)
{
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
Yodo1U3dAppOpenAd.GetInstance().ShowAd();
}
private void OnAppOpenAdLoadFailedEvent(Yodo1U3dAppOpenAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad request fails.
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
Invoke("LoadAppOpenAd", (float) retryDelay);
}
private void OnAppOpenAdOpenedEvent(Yodo1U3dAppOpenAd ad)
{
// Code to be executed when an ad opened
}
private void OnAppOpenAdOpenFailedEvent(Yodo1U3dAppOpenAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad open fails.
}
private void OnAppOpenAdClosedEvent(Yodo1U3dAppOpenAd ad)
{
// Code to be executed when the ad closed
}
}
public class AppOpenActivity extends Activity implements Yodo1MasAppOpenAdListener {
private final Handler handler = new Handler(Looper.getMainLooper());
private int retryAttempt;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_open);
Yodo1MasAppOpenAd.getInstance().setAdListener(this);
Yodo1MasAppOpenAd.getInstance().autoDelayIfLoadFail = true;
Yodo1MasAppOpenAd.getInstance().loadAd(this);
}
@Override
public void onAppOpenAdLoaded(Yodo1MasAppOpenAd ad) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
Yodo1MasAppOpenAd.getInstance().showAd(this);
// Show ad with placement name, like app_start, level_end
//Yodo1MasAppOpenAd.getInstance().showAd(this, "Your placement id");
}
@Override
public void onAppOpenAdFailedToLoad(Yodo1MasAppOpenAd ad, @NonNull Yodo1MasError error) {
// Code to be executed when an ad request fails.
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis((long) Math.pow(2, Math.min(5, retryAttempt)));
handler.postDelayed(new Runnable() {
@Override
public void run() {
Yodo1MasAppOpenAd.getInstance().loadAd(this);
}
}, delayMillis);
}
@Override
public void onAppOpenAdOpened(Yodo1MasAppOpenAd ad) {
// Code to be executed when an ad opened
}
@Override
public void onAppOpenAdFailedToOpen(Yodo1MasAppOpenAd ad, @NonNull Yodo1MasError error) {
// Code to be executed when an ad open fails.
Yodo1MasAppOpenAd.getInstance().loadAd(this);
}
@Override
public void onAppOpenAdClosed(Yodo1MasAppOpenAd ad) {
// Code to be executed when the user is about to return
// to the app after tapping on an ad.
Yodo1MasAppOpenAd.getInstance().loadAd(this);
}
}
class AppOpenActivity : Activity(), Yodo1MasAppOpenAdListener {
private val handler = Handler(Looper.getMainLooper()!!)
private var retryAttempt = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_app_open)
Yodo1MasAppOpenAd.getInstance().setAdListener(this)
Yodo1MasAppOpenAd.getInstance().autoDelayIfLoadFail = true
Yodo1MasAppOpenAd.getInstance().loadAd(this)
}
override fun onAppOpenAdLoaded(ad: Yodo1MasAppOpenAd) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0
// Show ad without placement name
Yodo1MasAppOpenAd.getInstance().showAd(this)
// Show ad with placement name, like app_start, level_end
// Yodo1MasAppOpenAd.getInstance().showAd(this, "Your placement id")
}
override fun onAppOpenAdFailedToLoad(ad: Yodo1MasAppOpenAd, error: Yodo1MasError ) {
// Code to be executed when an ad request fails.
retryAttempt++
val delayMillis = TimeUnit.SECONDS.toMillis(2.toDouble().pow(5.coerceAtMost(retryAttempt)).toLong())
handler.postDelayed({
Yodo1MasAppOpenAd.getInstance().loadAd(this)
}, delayMillis)
}
override fun onAppOpenAdOpened(ad: Yodo1MasAppOpenAd) {
// Code to be executed when an ad opens an overlay that
// covers the screen.
}
override fun onAppOpenAdFailedToOpen(ad: Yodo1MasAppOpenAd, error: Yodo1MasError) {
// Code to be executed when an ad open fails.
Yodo1MasAppOpenAd.getInstance().loadAd(this)
}
override fun onAppOpenAdClosed(ad: Yodo1MasAppOpenAd) {
// Code to be executed when the user is about to return
// to the app after tapping on an ad.
Yodo1MasAppOpenAd.getInstance().loadAd(this)
}
}
class AppOpenController: UIViewController {
private var retryAttempt = 0
override func viewDidLoad() {
super.viewDidLoad()
Yodo1MasAppOpenAd.sharedInstance().adDelegate = self
Yodo1MasAppOpenAd.sharedInstance().autoDelayIfLoadFail = true
Yodo1MasAppOpenAd.sharedInstance().load()
}
}
extension AppOpenController: Yodo1MasAppOpenAdDelegate {
func onAppOpenAdLoaded(_ ad: Yodo1MasAppOpenAd) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0
// Show ad without placement name
Yodo1MasAppOpenAd.sharedInstance().show()
// Show ad with placement name, like app_start, level_end
// Yodo1MasAppOpenAd.sharedInstance().show(withPlacement: "Your placement id")
}
func onAppOpenAdFailed(toLoad ad: Yodo1MasAppOpenAd, withError error: Yodo1MasError) {
// Code to be executed when an ad request fails.
retryAttempt+=1
let delaySec = NSDecimalNumber(decimal: pow(2, min(5, retryAttempt))).doubleValue
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delaySec) {
Yodo1MasAppOpenAd.sharedInstance().load()
}
}
func onAppOpenAdOpened(_ ad: Yodo1MasAppOpenAd) {
// Code to be executed when an ad opened
}
func onAppOpenAdFailed(toOpen ad: Yodo1MasAppOpenAd, withError error: Yodo1MasError) {
// Code to be executed when an ad open fails.
Yodo1MasAppOpenAd.sharedInstance().load()
}
func onAppOpenAdClosed(_ ad: Yodo1MasAppOpenAd) {
// Code to be executed when the ad closed
Yodo1MasAppOpenAd.sharedInstance().load()
}
}
@interface AppOpenViewController()
@property (nonatomic, assign) NSInteger retryAttempt;
@end
@implementation AppOpenViewController
- (void)viewDidLoad {
[super viewDidLoad];
[Yodo1MasAppOpenAd sharedInstance].adDelegate = self;
[Yodo1MasAppOpenAd sharedInstance].autoDelayIfLoadFail = YES;
[[Yodo1MasAppOpenAd sharedInstance] loadAd];
}
#pragma mark - Yodo1MasAppOpenAdDelegate
- (void)onAppOpenAdLoaded:(Yodo1MasAppOpenAd *)ad {
// Code to be executed when an ad finishes loading.
_retryAttempt = 0;
// Show ad without placement name
[[Yodo1MasAppOpenAd sharedInstance] showAd];
// Show ad with placement name, like app_start, level_end
// [[Yodo1MasAppOpenAd sharedInstance] showAdWithPlacement:@"Your placement id"];
}
- (void)onAppOpenAdFailedToLoad:(Yodo1MasAppOpenAd *)ad withError:(Yodo1MasError *)error {
// Code to be executed when an ad request fails.
_retryAttempt++;
NSInteger delaySec = pow(2, MIN(5, self.retryAttempt));
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[[Yodo1MasAppOpenAd sharedInstance] loadAd];
});
}
- (void)onAppOpenAdOpened:(Yodo1MasAppOpenAd *)ad {
// Code to be executed when an ad opened
}
- (void)onAppOpenAdFailedToOpen:(Yodo1MasAppOpenAd *)ad withError:(Yodo1MasError *)error {
// Code to be executed when an ad open fails.
[[Yodo1MasAppOpenAd sharedInstance] loadAd];
}
- (void)onAppOpenAdClosed:(Yodo1MasAppOpenAd *)ad {
// Code to be executed when the ad closed
[[Yodo1MasAppOpenAd sharedInstance] loadAd];
}
@end
To show App Open Ads, just enable the AppOpenAds checkbox in the editor as shown in the screenshot.
Note : App Open Ads option will only work once the game is live.
Video Tutorial
Best Practices
- It is required to show a splash screen or loading screen before the App Open Ad.
- Ensure that MAS SDK is initialized before you load an app open ad.
- When an app open ad is not loaded (i.e. on cold start), only load app open ads first and load all other ad formats later to avoid parallel loading with the app open ad. See here, Optimize App Open Ad Loading Time.