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
- React Native
Yodo1U3dAppOpenAd.GetInstance().LoadAd();
Yodo1MasAppOpenAd.getInstance().loadAd(MainActivity.this);
Yodo1MasAppOpenAd.getInstance().loadAd(this@MainActivity)
Yodo1MasAppOpenAd.sharedInstance().load()
[[Yodo1MasAppOpenAd sharedInstance] loadAd];
const App = () => {
Yodo1MASAds.showAppOpenAds();
//...
}
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
- React Native
// 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
No need to configure on React Native
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
- React Native
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
useEffect(() => {
Yodo1MASAds.showAppOpenAdsWithPlacementId("Your Placement ID");
}, []);
Configure the ad events
The MAS SDK fires several events to inform you of ad availability.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
- React Native
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()<Yodo1MasAppOpenAdDelegate>
@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.
const handleEvents = ({value}) => {
__DEV__ && console.log(`Event: ${value}`);
switch (value) {
case 'onAppOpenAdLoaded':
// Handle the event when the ad is loaded
break;
case 'onAppOpenAdOpened':
// Handle the event when the ad is opened
break;
case 'onAppOpenAdClosed':
// Handle the event when the ad is closed
break;
case 'onAppOpenAdFailedToLoad':
// Ad failed to load, let's try again after a delay
break;
case 'onAppOpenAdFailedToOpen':
// Ad failed to open, let's try again after a delay
break;
}
};
export const registerYodo1MAS = () => {
const eventEmitter = new NativeEventEmitter(Yodo1MASAds);
const eventListener = eventEmitter.addListener('adEvent', handleEvents);
// If needed, pass CCPA, COPPA, GDPR values in the initSDK method
Yodo1MASAds.initMasSdk(true, true, true);
return eventListener;
};
Impression-Level User Revenue
Starting in SDK version 4.13.2, you can access impression-level user revenue data on the client side. You can use this data to compare different sources and campaigns.
You can share impression-level ad revenue data with your mobile measurement partner of choice.
You can retrieve the revenue amount in all ad lifecycle callbacks. The following example shows how to do this within callback:
- Unity
- Java
- Kotlin
- Swift
- Objective-C
Yodo1U3dAppOpenAd.GetInstance().OnAdPayRevenueEvent += OnAppOpenAdPayRevenueEvent;
private void OnAppOpenAdPayRevenueEvent(Yodo1U3dAppOpenAd ad, Yodo1U3dAdValue adValue)
{
double revenue = adValue.Revenue;
string currency = adValue.Currency;
}
Yodo1MasAppOpenAd.getInstance().setAdRevenueListener(new Yodo1MasAppOpenAdRevenueListener() {
@Override
public void onAppOpenAdPayRevenue(Yodo1MasAppOpenAd ad, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
}
});
Yodo1MasAppOpenAd.getInstance().setAdRevenueListener { ad, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
}
Yodo1MasAppOpenAd.sharedInstance().adRevenueDelegate = self
func onAppOpenAdPayRevenue(_ ad: Yodo1MasAppOpenAd, _ adValue: Yodo1MasAdValue)
{
let revenue = adValue.revenue
let currency = adValue.currency
}
[Yodo1MasAppOpenAd sharedInstance].adRevenueDelegate = self;
#pragma mark - Yodo1MasAppOpenAdRevenueDelegate
- (void)onAppOpenAdPayRevenue:(Yodo1MasAppOpenAd *)ad withAdValue:(Yodo1MasAdValue *)adValue {
double revenue = adValue.revenue;
NSString *currency = adValue.currency;
}
You can also retrieve a precision evaluation for the revenue value, as shown in the following example:
- Unity
- Java
- Kotlin
- Swift
- Objective-C
string revenuePrecision = adValue.RevenuePrecision;
String revenuePrecision = adValue.getRevenuePrecision();
val revenuePrecision = adValue.revenuePrecision
let revenuePrecision = adValue.revenuePrecision
NSString *revenuePrecision = adValue.revenuePrecision;
This precision takes one of the following values:
"publisher_defined": the revenue amount is the price assigned by the publisher
"exact": the revenue amount is the result of a real-time auction
"estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
"": revenue and precision are not valid (for example, in test mode)
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.