Interstitial 광고

Interstitial ads는 앱의 인터페이스를 일시적으로 덮는 전체 화면 또는 전체 페이지 광고입니다. 일반적으로 게임에서 레벨을 완료한 후나 주요 뷰 사이를 이동할 때와 같이 자연스러운 일시 중지 또는 전환 시점에 표시됩니다.

다음 섹션에서는 interstitial ad를 로드한 다음 보여주는 방법을 설명합니다.

interstitial ad 로드하기

다음 코드는 리스너를 등록하고 첫 번째 interstitial ad를 로드하는 방법을 보여줍니다.


const INTERSTITIAL_AD_UNIT_ID = Platform.select({
  android: '«android-ad-unit-ID»',
  ios: '«ios-ad-unit-ID»',
});

const MAX_EXPONENTIAL_RETRY_COUNT = 6;
const retryAttempt = useRef(0);

const initializeInterstitialAds = () => {
  InterstitialAd.addAdLoadedEventListener((adInfo: AdInfo) => {
    // Interstitial ad is ready to show. InterstitialAd.isAdReady(INTERSTITIAL_AD_UNIT_ID) now returns 'true'

    // Reset retry attempt
    retryAttempt.current = 0;
  });
  InterstitialAd.addAdLoadFailedEventListener((errorInfo: AdLoadFailedInfo) => {
    // 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.current += 1;
    if (retryAttempt.current > MAX_EXPONENTIAL_RETRY_COUNT) return;
    const retryDelay = Math.pow(2, Math.min(MAX_EXPONENTIAL_RETRY_COUNT, retryAttempt.current));

    console.log('Interstitial ad failed to load - retrying in ' + retryDelay + 's');

    setTimeout(function() {
      loadInterstitial();
    }, retryDelay * 1000);
  });
  InterstitialAd.addAdClickedEventListener((adInfo: AdInfo) => { ... });
  InterstitialAd.addAdDisplayedEventListener((adInfo: AdInfo) => { ... });
  InterstitialAd.addAdFailedToDisplayEventListener((adInfo: AdDisplayFailedInfo) => {
    // Interstitial ad failed to display. AppLovin recommends that you load the next ad
    loadInterstitial();
  });
  InterstitialAd.addAdHiddenEventListener((adInfo: AdInfo) => {
    loadInterstitial();
  });

  // Load the first interstitial
  loadInterstitial();
}

const loadInterstitial = () => {
  InterstitialAd.loadAd(INTERSTITIAL_AD_UNIT_ID);
}

interstitial ad 보여주기

showAd()를 호출하여 interstitial ad를 보여줍니다.

const isInterstitialReady = await InterstitialAd.isAdReady(«ad-unit-ID»);
if (isInterstitialReady) {
  InterstitialAd.showAd(«ad-unit-ID»);
}

search