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
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();
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
- Flutter
// 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 Godot
Display the ad
- Unity
- Java
- Kotlin
- Swift
- Objective-C
- Unreal
- Godot
- Flutter
- Cocos2D
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()
Yodo1MAS.instance.showInterstitialAd();
Yodo1Ads.getInstance().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
- Flutter
- Cocos2D
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()
@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)onInterstitialLoaded:(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)onInterstitialFailedToLoad:(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)onInterstitialOpened:(Yodo1MasInterstitialAd *)ad {
// Code to be executed when an ad opened
}
- (void)onInterstitialFailedToOpen:(Yodo1MasInterstitialAd *)ad withError:(Yodo1MasError *)error {
// Code to be executed when an ad open fails.
[[Yodo1MasInterstitialAd sharedInstance] loadAd];
}
- (void)onInterstitialClosed:(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():
Yodo1MAS.instance.setInterstitialListener((event, message) {
switch(event) {
case Yodo1MAS.AD_EVENT_OPENED:
print('Interstitial AD_EVENT_OPENED');
break;
case Yodo1MAS.AD_EVENT_ERROR:
print('Interstitial AD_EVENT_ERROR' + message);
break;
case Yodo1MAS.AD_EVENT_CLOSED:
print('Interstitial AD_EVENT_CLOSED');
break;
}});
public onInterstitialAdLoaded() {
}
public onInterstitialAdFailedToLoad() {
}
public onInterstitialAdOpened() {
}
public onInterstitialAdFailedToOpen() {
}
public onInterstitialAdClosed() {
}
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.