Legacy Documentation: Version 5.3
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ADInterstitialAd

class in UnityEngine.iOS

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

ADInterstitialAd is a wrapper around the ADInterstitialAd class found in the Apple iAd framework and is only available on iPad.

It provides full-screen advertisements that your iPad application can display to the user.

#pragma strict
ADInterstitialAdUnityEngine.iOS.ADInterstitialAdpublic class NewBehaviourScript extends MonoBehaviour {
	private var fullscreenAd: ADInterstitialAd = null;
	function Start() {
		fullscreenAd = new ADInterstitialAd();
		ADInterstitialAd.onInterstitialWasLoaded += OnFullscreenLoaded;
		ADInterstitialAd.onInterstitialWasViewed += OnFullscreenViewed;
	}
	function WantToShowAD() {
		if (fullscreenAd.loaded)
			fullscreenAd.Show();
		else
			fullscreenAd.ReloadAd();
	}
	function OnFullscreenLoaded() {
		// you can show ad right here, or, for example, you can start preparing your UI
		Debug.Log("AD Loaded\n");
	}
	function OnFullscreenViewed() {
		// You can also start reloading the Ad here if you are not using built-in auto reloading.
		Debug.Log("AD Viewed\n");
		fullscreenAd.ReloadAd();
	}
	function OnGUI() {
		if (GUI.Button(new Rect(20, 20, 200, 200), "AD"))
			WantToShowAD();
	}
}
using UnityEngine;
using System.Collections;

using ADInterstitialAd = UnityEngine.iOS.ADInterstitialAd;

public class NewBehaviourScript : MonoBehaviour {

private ADInterstitialAd fullscreenAd = null;

void Start() { fullscreenAd = new ADInterstitialAd(); ADInterstitialAd.onInterstitialWasLoaded += OnFullscreenLoaded; ADInterstitialAd.onInterstitialWasViewed += OnFullscreenViewed; }

void WantToShowAD() { if(fullscreenAd.loaded) fullscreenAd.Show(); else fullscreenAd.ReloadAd(); }

void OnFullscreenLoaded() { // you can show ad right here, or, for example, you can start preparing your UI Debug.Log("AD Loaded\n"); } void OnFullscreenViewed() { // If we reach this stage, it means the user viewed the Ad past the initial screen. // This could be a good point to reward the user (eg. give an in-game bonus item). // You can also start reloading the Ad here if you are not using built-in auto reloading. Debug.Log("AD Viewed\n"); fullscreenAd.ReloadAd(); }

void OnGUI() { if(GUI.Button(new Rect(20,20,200,200), "AD")) WantToShowAD(); }

}

Please note that this class is a thin wrapper around the iOS native iAD class, so care should be taken when creating/destroying instances of it frequently. If you need to show ads frequently, instead of constantly destroying and recreating the object you should manually call ReloadAd, or create an auto-reloading ADInterstitialAd.

Static Variables

isAvailableChecks if InterstitialAd is available (it is available on iPad since iOS 4.3, and on iPhone since iOS 7.0).

Variables

loadedHas the interstitial ad object downloaded an advertisement? (Read Only)

Constructors

ADInterstitialAdCreates an interstitial ad.

Public Functions

ReloadAdReload advertisement.
ShowShows full-screen advertisement to user.

Delegates

InterstitialWasLoadedDelegateWill be called when ad is ready to be shown.
InterstitialWasViewedDelegateWill be called when user viewed ad contents: i.e. they went past the initial screen. Please note that it is impossible to determine if they clicked on any links in ad sequences that follows the initial screen.