Interstitial Ads
Interstitial ad units show full-page ads in your app. Place them at natural breaks & transitions in your app's interface, such as after level completion in a gaming app.
Benefits of Interstitial Ads
- Engaging content
- Full-screen size
- Media content can be static, video-based or interactive
- Positive UX
- Placement in natural transition points improves overall user experience (UX)
You should finish these steps before releasing.
Load the ad
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Unreal
- Godot
- Cocos2D
- React Native
Yodo1U3dInterstitialAd.GetInstance().LoadAd();
Yodo1MasInterstitialAd.getInstance().loadAd(MainActivity.this);
Yodo1MasInterstitialAd.getInstance().loadAd(this@MainActivity);
Yodo1MasInterstitialAd.sharedInstance().loadAd()
[[Yodo1MasInterstitialAd sharedInstance] loadAd];
yodo1mas.load_interstitial_ads()
Yodo1Ads.getInstance().initializeInterstitialAds();
// Interstitial ads are pre-loaded automatically
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad needs to be loaded immediately on OnAdLoadFailedEvent()
, then the auto delay config variable must be set to true to limit ad load retries to avoid continuous failed ad requests to avoid ANR issues.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Godot
- React Native
// Remember to call this function before SDK init.
Yodo1U3dInterstitialAd.GetInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasInterstitialAd.autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasInterstitialAd.autoDelayIfLoadFail = true
// Remember to call this function before SDK init.
Yodo1MasInterstitialAd.sharedInstance().autoDelayIfLoadFail = true
// Remember to call this function before SDK init.
[Yodo1MasInterstitialAd sharedInstance].autoDelayIfLoadFail = YES;
// No need to configure on Godot
// No need to configure on React Native
Display the ad
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Unreal
- Godot
- Cocos2D
- React Native
bool isLoaded = Yodo1U3dInterstitialAd.GetInstance().IsLoaded();
// Show ad with placement name, like app_start, level_end
if (isLoaded)
{
Yodo1U3dInterstitialAd.GetInstance().ShowAd("Your Placement Id");
}
// Show ad without placement name
if (isLoaded)
{
Yodo1U3dInterstitialAd.GetInstance().ShowAd();
}
boolean isLoaded = Yodo1MasInterstitialAd.getInstance().isLoaded();
// Show ad without placement name
if(isLoaded) Yodo1MasInterstitialAd.getInstance().showAd(MainActivity.this);
// Show ad with placement name, like app_start, level_end
if(isLoaded) Yodo1MasInterstitialAd.getInstance().showAd(MainActivity.this, "Your Placement Id");
val isLoaded = Yodo1MasInterstitialAd.getInstance().isLoaded()
// Show ad without placement name
if(isLoaded) Yodo1MasInterstitialAd.getInstance().showAd(this@MainActivity)
// Show ad with placement name, like app_start, level_end
if(isLoaded) Yodo1MasInterstitialAd.getInstance().showAd(this@MainActivity, "Your Placement Id")
let isLoaded = Yodo1MasInterstitialAd.sharedInstance().isLoaded()
// Show ad without placement name
if isLoaded { Yodo1MasInterstitialAd.sharedInstance().showAd() }
// Show ad with placement name, like app_start, level_end
if isLoaded { Yodo1MasInterstitialAd.sharedInstance().showAd(withPlacement: "Your Placement Id") }
BOOL isLoaded = [[Yodo1MasInterstitialAd sharedInstance] isLoaded];
// Show ad without placement name
if(isLoaded) [[Yodo1MasInterstitialAd sharedInstance] showAd];
// Show ad with placement name, like app_start, level_end
if(isLoaded) [[Yodo1MasInterstitialAd sharedInstance] showAdWithPlacement:@"Your Placement Id"];
var is_interstitial_loaded = yodo1mas.is_interstitial_ad_loaded()
if is_interstitial_loaded:
yodo1mas.show_interstitial_ad()
Yodo1Ads.getInstance().showInterstitialAds();
// Recommended, show interstitial ads with placement name
Yodo1MASAds.showInterstitialAdsWithPlacementId("Your Placement Id");
// Show interstitial ads without placement name
Yodo1MASAds.showInterstitialAds();
Configure the ad events
The MAS SDK fires several events to inform you of ad availability.
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Unreal
- Godot
- Cocos2D
- React Native
using Yodo1.MAS;
public class InterstitialAdLoader : MonoBehaviour
{
private int retryAttempt = 0;
private void Start()
{
SetupEventCallbacks();
LoadInterstitialAd();
}
private void SetupEventCallbacks()
{
Yodo1U3dInterstitialAd.GetInstance().OnAdLoadedEvent += OnInterstitialAdLoadedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdLoadFailedEvent += OnInterstitialAdLoadFailedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdOpenedEvent += OnInterstitialAdOpenedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdOpenFailedEvent += OnInterstitialAdOpenFailedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdClosedEvent += OnInterstitialAdClosedEvent;
}
private void LoadInterstitialAd()
{
Yodo1U3dInterstitialAd.GetInstance().LoadAd();
}
private void OnInterstitialAdLoadedEvent(Yodo1U3dInterstitialAd ad)
{
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
Yodo1U3dInterstitialAd.GetInstance().ShowAd();
}
private void OnInterstitialAdLoadFailedEvent(Yodo1U3dInterstitialAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad request fails.
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
Invoke("LoadInterstitialAd", (float) retryDelay);
}
private void OnInterstitialAdOpenedEvent(Yodo1U3dInterstitialAd ad)
{
// Code to be executed when an ad opened
}
private void OnInterstitialAdOpenFailedEvent(Yodo1U3dInterstitialAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad open fails.
LoadInterstitialAd();
}
private void OnInterstitialAdClosedEvent(Yodo1U3dInterstitialAd ad)
{
// Code to be executed when the ad closed
LoadInterstitialAd();
}
}
public class InterstitialActivity extends Activity implements Yodo1MasInterstitialAdListener {
private final Handler handler = new Handler(Looper.getMainLooper());
private int retryAttempt;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_interstitial);
Yodo1MasInterstitialAd.getInstance().setAdListener(this);
Yodo1MasInterstitialAd.getInstance().autoDelayIfLoadFail = true;
Yodo1MasInterstitialAd.getInstance().loadAd(this);
}
@Override
public void onInterstitialAdLoaded(Yodo1MasInterstitialAd ad) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
// Show ad without placement name
Yodo1MasInterstitialAd.getInstance().showAd(this);
// Show ad with placement name, like app_start, level_end
// Yodo1MasInterstitialAd.getInstance().showAd(this, "Your Placement Id");
}
@Override
public void onInterstitialAdFailedToLoad(Yodo1MasInterstitialAd 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() {
Yodo1MasInterstitialAd.getInstance().loadAd(this);
}
}, delayMillis);
}
@Override
public void onInterstitialAdOpened(Yodo1MasInterstitialAd ad) {
// Code to be executed when an ad opened
}
@Override
public void onInterstitialAdFailedToOpen(Yodo1MasInterstitialAd ad, @NonNull Yodo1MasError error) {
// Code to be executed when an ad open fails.
Yodo1MasInterstitialAd.getInstance().loadAd(this);
}
@Override
public void onInterstitialAdClosed(Yodo1MasInterstitialAd ad) {
// Code to be executed when the ad closed
Yodo1MasInterstitialAd.getInstance().loadAd(this);
}
}
class InterstitialActivity: Activity(), Yodo1MasInterstitialAdListener {
private val handler = Handler(Looper.getMainLooper()!!)
private var retryAttempt = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_interstitial)
Yodo1MasInterstitialAd.getInstance().setAdListener(this)
Yodo1MasInterstitialAd.getInstance().autoDelayIfLoadFail = true
Yodo1MasInterstitialAd.getInstance().loadAd(this)
}
override fun onInterstitialAdLoaded(ad: Yodo1MasInterstitialAd) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0
// Show ad without placement name
Yodo1MasInterstitialAd.getInstance().showAd(this)
// Show ad with placement name, like app_start, level_end
// Yodo1MasInterstitialAd.getInstance().showAd(this, "Your Placement Id")
}
override fun onInterstitialAdFailedToLoad(ad: Yodo1MasInterstitialAd, 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({
Yodo1MasInterstitialAd.getInstance().loadAd(this)
}, delayMillis)
}
override fun onInterstitialAdOpened(ad: Yodo1MasInterstitialAd) {
// Code to be executed when an ad opened
}
override fun onInterstitialAdFailedToOpen(ad: Yodo1MasInterstitialAd, error: Yodo1MasError) {
// Code to be executed when an ad open fails.
Yodo1MasInterstitialAd.getInstance().loadAd(this)
}
override fun onInterstitialAdClosed(ad: Yodo1MasInterstitialAd) {
// Code to be executed when the ad closed
Yodo1MasInterstitialAd.getInstance().loadAd(this)
}
}
class InterstitialController: UIViewController {
private var retryAttempt = 0
override func viewDidLoad() {
super.viewDidLoad();
Yodo1MasInterstitialAd.sharedInstance().adDelegate = self
Yodo1MasInterstitialAd.sharedInstance().autoDelayIfLoadFail = true
Yodo1MasInterstitialAd.sharedInstance().load()
}
}
extension InterstitialController: Yodo1MasInterstitialDelegate {
func onInterstitialAdLoaded(_ ad: Yodo1MasInterstitialAd) {
// Code to be executed when an ad finishes loading.
retryAttempt = 0
// Show ad without placement name
Yodo1MasInterstitialAd.sharedInstance().show()
// Show ad with placement name, like app_start, level_end
// Yodo1MasInterstitialAd.sharedInstance().show(withPlacement: "Your placement ID")
}
func onInterstitialAdFailed(toLoad ad: Yodo1MasInterstitialAd, 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) {
Yodo1MasInterstitialAd.sharedInstance().load()
}
}
func onInterstitialAdOpened(_ ad: Yodo1MasInterstitialAd) {
// Code to be executed when an ad opened
}
func onInterstitialAdFailed(toOpen ad: Yodo1MasInterstitialAd, withError error: Yodo1MasError) {
// Code to be executed when an ad open fails.
Yodo1MasInterstitialAd.sharedInstance().loadAd()
}
func onInterstitialAdClosed(_ ad: Yodo1MasInterstitialAd) {
// Code to be executed when the ad closed
Yodo1MasInterstitialAd.sharedInstance().loadAd()
}
}
@interface InterstitialViewController()<Yodo1MasInterstitialDelegate>
@property (nonatomic, assign) NSInteger retryAttempt;
@end
@implementation InterstitialViewController
- (void)viewDidLoad {
[super viewDidLoad];
[Yodo1MasInterstitialAd sharedInstance].adDelegate = self;
[Yodo1MasInterstitialAd sharedInstance].autoDelayIfLoadFail = YES;
[[Yodo1MasInterstitialAd sharedInstance] loadAd];
}
#pragma mark - Yodo1MasInterstitialDelegate
- (void)onInterstitialAdLoaded:(Yodo1MasInterstitialAd *)ad {
// Code to be executed when an ad finishes loading.
_retryAttempt = 0;
// Show ad without placement name
[[Yodo1MasInterstitialAd sharedInstance] showAd];
// Show ad with placement name, like app_start, level_end
// [[Yodo1MasInterstitialAd sharedInstance] showAdWithPlacement:@"Your placement ID"];
}
- (void)onInterstitialAdFailedToLoad:(Yodo1MasInterstitialAd *)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(), ^{
[[Yodo1MasInterstitialAd sharedInstance] loadAd];
});
}
- (void)onInterstitialAdOpened:(Yodo1MasInterstitialAd *)ad {
// Code to be executed when an ad opened
}
- (void)onInterstitialAdFailedToOpen:(Yodo1MasInterstitialAd *)ad withError:(Yodo1MasError *)error {
// Code to be executed when an ad open fails.
[[Yodo1MasInterstitialAd sharedInstance] loadAd];
}
- (void)onInterstitialAdClosed:(Yodo1MasInterstitialAd *)ad {
// Code to be executed when the ad closed
[[Yodo1MasInterstitialAd sharedInstance] loadAd];
}
@end
func _on_Yodo1Mas_interstitial_ad_loaded():
func _on_Yodo1Mas_interstitial_ad_not_loaded():
func _on_Yodo1Mas_interstitial_ad_opened():
func _on_Yodo1Mas_interstitial_ad_failed_to_opened():
func _on_Yodo1Mas_interstitial_ad_closed():
public onInterstitialAdLoaded() {
}
public onInterstitialAdFailedToLoad() {
}
public onInterstitialAdOpened() {
}
public onInterstitialAdFailedToOpen() {
}
public onInterstitialAdClosed() {
}
const handleEvents = ({value}) => {
__DEV__ && console.log(`Event: ${value}`);
switch (value) {
case 'onInterstitialAdLoadedLoaded':
// Handle the event when the ad is loaded
break;
case 'onInterstitialAdLoadedOpened':
// Handle the event when the ad is opened
break;
case 'onInterstitialAdLoadedClosed':
// Handle the event when the ad is closed
break;
case 'onInterstitialAdLoadedFailedToLoad':
// Ad failed to load, let's try again after a delay
break;
case 'onInterstitialAdLoadedFailedToOpen':
// 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
Yodo1U3dInterstitialAd.GetInstance().OnAdPayRevenueEvent += OnInterstitialAdPayRevenueEvent;
private void OnInterstitialAdPayRevenueEvent(Yodo1U3dInterstitialAd ad, Yodo1U3dAdValue adValue)
{
double revenue = adValue.Revenue;
string currency = adValue.Currency;
}
Yodo1MasInterstitialAd.getInstance().setAdRevenueListener(new Yodo1MasInterstitialAdRevenueListener() {
@Override
public void onInterstitialAdPayRevenue(Yodo1MasInterstitialAd ad, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
}
});
Yodo1MasInterstitialAd.getInstance().setAdRevenueListener { ad, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
}
Yodo1MasInterstitialAd.sharedInstance().adRevenueDelegate = self
func onInterstitialAdPayRevenue(_ ad: Yodo1MasRewardAd, _ adValue: Yodo1MasAdValue)
{
let revenue = adValue.revenue
let currency = adValue.currency
}
[Yodo1MasInterstitialAd sharedInstance].adRevenueDelegate = self;
#pragma mark - Yodo1MasInterstitialAdRevenueDelegate
- (void)onInterstitialAdPayRevenue:(Yodo1MasInterstitialAd *)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
1. Preload
We recommend that you preload the interstitial ad before showing it. This will ensure the ad is ready to be displayed when needed.
2. Placement
We recommend setting the placement name when you show the ad. This will help you track each placement's performance in the dashboard.
3. Handle Failures
If the ad fails to load, you should NOT try to reload immediately. Instead, it would be best if you waited a while before reloading the ad again. We recommend waiting at least 10 seconds before trying to fill the ad.