コンテンツにスキップ

インタースティシャル広告

インタースティシャル広告は、アプリのインターフェイスを一時的に覆う、フル画面またはフルページ広告です。 この広告は、一般的に、ゲームのレベル完了後や主要な画面間の遷移時など、アプリ内の自然な区切りや遷移ポイントで表示されます。

次のセクションでは、インタースティシャル広告をロードし、表示する方法について説明します。

インタースティシャル広告をロード

以下のコードは、イベントリスナーを付与して最初のインタースティシャル広告をロードする方法を示しています。

var interstitialAdUnitId:String = "«ad-unit-ID»";
var retryAttempt:Number;
public function initializeInterstitialAds():void
{
// Attach event callbacks
AppLovinMAXEvents.setInterstitialLoadedEvent(onInterstitialLoaded);
AppLovinMAXEvents.setInterstitialLoadFailedEvent(onInterstitialLoadFailed);
AppLovinMAXEvents.setInterstitialDisplayedEvent(onInterstitialDisplayed);
AppLovinMAXEvents.setInterstitialFailedToDisplayEvent(onInterstitialFailedToDisplay);
AppLovinMAXEvents.setInterstitialClickedEvent(onInterstitialClicked);
AppLovinMAXEvents.setInterstitialHiddenEvent(onInterstitialHidden);
// Load the first interstitial
loadInterstitial();
}
private function loadInterstitial()
{
AppLovinMAX.loadInterstitial(interstitialAdUnitId);
}
private function onInterstitialLoaded(adEventInfo:AdEventInfo):void
{
// Interstitial ad is ready for you to show. AppLovinMAX.isInterstitialReady(adUnitId) now returns 'true'
// Reset retry attempt
retryAttempt = 0;
}
private function onInterstitialLoadFailed(adEventInfo:AdEventInfo):void
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds)
retryAttempt++;
var retryDelay:Number = Math.pow(2, Math.min(6, retryAttempt));
var timer:Timer = new Timer(retryDelay, 1);
timer.addEventListener(TimerEvent.TIMER, loadInterstitial);
timer.start();
}
private function onInterstitialDisplayed(adEventInfo:AdEventInfo):void {}
private function onInterstitialFailedToDisplay(adEventInfo:AdEventInfo):void
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
loadInterstitial();
}
private static function onInterstitialClicked(adEventInfo:AdEventInfo):void {}
private function onInterstitialHidden(adEventInfo:AdEventInfo):void
{
// Interstitial ad is hidden. Pre-load the next ad.
loadInterstitial();
}

インタースティシャル広告を表示

インタースティシャル広告を表示するには、showInterstitial()を呼び出します。

if (AppLovinMAX.isInterstitialReady(«ad-unit-ID»))
{
AppLovinMAX.showInterstitial(«ad-unit-ID»)
}