Interstitial 광고

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

다음 섹션에서는 interstitial ad를 로드하고 표시하는 방법을 보여줍니다.

interstitial ad 로드하기

interstitial ad를 로드하려면 광고 단위에 해당하는 MAInterstitialAd 객체를 인스턴스화하고 해당 loadAd() 메서드를 호출합니다. 광고가 준비되었을 때 알림을 받을 수 있도록 MAAdDelegate를 구현하세요. 이를 통해 다른 광고 관련 이벤트에 대한 알림도 받을 수 있습니다.

#import "ExampleViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>

@interface ExampleViewController()<MAAdDelegate>
@property (nonatomic, strong) MAInterstitialAd *interstitialAd;
@property (nonatomic, assign) NSInteger retryAttempt;
@end

@implementation ExampleViewController

- (void)createInterstitialAd
{
  self.interstitialAd = [[MAInterstitialAd alloc] initWithAdUnitIdentifier: @"«ad-unit-ID»"];
  self.interstitialAd.delegate = self;

  // Load the first ad
  [self.interstitialAd loadAd];
}

#pragma mark - MAAdDelegate Protocol

- (void)didLoadAd:(MAAd *)ad
{
  // Interstitial ad is ready to be shown. '[self.interstitialAd isReady]' will now return 'YES'

  // Reset retry attempt
  self.retryAttempt = 0;
}

- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error
{
  // Interstitial ad failed to load
  // AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)

  self.retryAttempt++;
  NSInteger delaySec = pow(2, MIN(6, self.retryAttempt));

  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    [self.interstitialAd loadAd];
  });
}

- (void)didDisplayAd:(MAAd *)ad {}

- (void)didClickAd:(MAAd *)ad {}

- (void)didHideAd:(MAAd *)ad
{
  // Interstitial ad is hidden. Pre-load the next ad
  [self.interstitialAd loadAd];
}

- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error
{
  // Interstitial ad failed to display. AppLovin recommends that you load the next ad.
  [self.interstitialAd loadAd];
}

@end

interstitial ad 표시하기

interstitial ad를 표시하려면 인스턴스화한 MAInterstitialAd 객체에서 showAd()를 호출합니다.

if ( [self.interstitialAd isReady] )
{
  [self.interstitialAd showAd];
}

interstitial ad 오디오가 앱의 배경 오디오를 방해하지 않도록 하기 위해, AppLovin은 didDisplayAd() 콜백이 실행될 때 앱의 배경 오디오를 일시 중지할 것을 권장합니다. 그 후 didHideAd() 콜백이 실행될 때 앱의 배경 오디오를 다시 시작할 수 있습니다.


search