iOS에서의 인터스티셜 광고 연동

유니티 레벨플레이 인터스티셜(전면) 광고는 전체화면 광고 유닛으로, 보통 앱의 생명주기 중 자연스러운 장면 전환 시점에 게재되는 광고입니다.

⚡ Before you start
    • 아이언소스 SDK가 대상 앱에 올바르게 연동이 되었는지 확인해 주세요. Integration is outlined 여기에서 연동과정 및 상세 사항에 대한 설명을 참조하세요..
    • 반드시 LevelPlay 초기화 API를 사용하여 SDK를 초기화해야 합니다.
    • AdUnitId는 레벨플레이 대시보드상에서 확인하실 수 있습니다. 자세한 사항은 여기를 참고해 주세요.
    • 이 문서는 아이언소스 SDK 8.4.0 이상 버전에 대해서만 유효합니다. 8.4.0 미만 버전의 인터스티셜 광고 API에 대한 문서는 여기에서 확인하실 수 있습니다.

    인터스티셜 광고 객체 생성

    인터스티셜 광고 객체 생성은 OnInitSuccess 콜백 수신 이후에 실행해야 합니다.

    self.interstitialAd = [[LPMInterstitialAd alloc] initWithAdUnitId:@"adUnitId"];
    • Light theme
    • Dark theme
    • Copy to clipboard

    대리자(delegate) 구현

    코드 상에 LPMInterstitialAdDelegate를 구현하여 광고 로드 및 송출 관련 정보를 수신할 수 있도록 합니다.

    • 인터스티셜 광고를 로드하기 전에 대리자를 설정하는 것이 좋습니다.
    • 각 인터스티셜 객체별로 대리자를 구현해야 설정해주어야 합니다.
    • 콜백은 메인스레드에서 실행됩니다.
    self.interstitialAd = [[LPMInterstitialAd alloc] initWithAdUnitId:@"adUnitId"]; 
    self.interstitialAd.delegate = self;
    
    #pragma mark - LPMInterstitialAdDelegate Methods
    - (void)didLoadAdWithAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didFailToLoadAdWithAdUnitId:(NSString *)adUnitId error:(NSError *)error {}
    - (void)didChangeAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didDisplayAdWithAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didFailToDisplayAdWithAdInfo:(LPMAdInfo *)adInfo error:(NSError *)error {}
    - (void)didClickAdWithAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didCloseAdWithAdInfo:(LPMAdInfo *)adInfo {}
    • Light theme
    • Dark theme
    • Copy to clipboard

    레벨플레이 Ad Info

    Ad Info LPMAdInfo 파라미터는 로드된 광고에 대한 정보가 포함되어 있습니다.

    해당 클래스의 구현 및 사용 가능한 필드들에 대한 정보는 여기를 참고해 주세요.

    인터스티셜 광고 로드

    loadAd API를 사용하여 인터스티셜 광고를 로드합니다.

    [self.interstitialAd loadAd];
    • Light theme
    • Dark theme
    • Copy to clipboard

    인터스티셜 광고 송출

    LPMInterstitialAdDelegate API를 통해 didLoadAd 콜백을 수신한 후, 로드된 인터스티셜 광고를 송출합니다.

    • 송출 API 호출 시 반드시 ViewController 객체를 파라미터로 넘겨줘야 합니다.
    • 플레이스먼트를 지정하여 사용할 경우, 아래의 플레이스먼트 섹션에서 설명된 것과 같이 플레이스먼트 명칭을 showAd API의 인자로 입력하여 전달합니다.
    • 광고가 사용자에게 성공적으로 송출이 된 후에는, 이전 인터스티셜 광고 로드 단계를 다시 실행해 다른 인터스티셜 광고를 로드할 수 있습니다. 
    - (void)showInterstitialAd {
        // Check that ad is ready
        if ([self.interstitialAd isAdReady]) {
            // Show without placement
            [self.interstitialAd showAdWithViewController:self placementName:NULL];
        }
    }
    • Light theme
    • Dark theme
    • Copy to clipboard

    광고 송출 준비 상태 확인

    송출 실패를 피하고 광고가 올바르게 송출되도록 하기 위해서는, showAd API 호출 전에 아래의 API를 사용하여 송출 준비 상태를 확인하는 것이 좋습니다.

    isAdReady – 광고가 성공적으로 로드되었고 광고 유닛이 송출 한도 제한에 걸리지 않은 상태일 경우 true가 반환되며, 그렇지 않을 경우에는 false가 반환됩니다.

    isPlacementCapped – 인자로 입력된 플레이스먼트가 유효한 플레이스먼트이며 송출 한도 제한이 유효한 경우에는 true가 반환됩니다. 플레이스먼트가 유효하지 않거나 송출 한도 제한이 걸려있지 않은 경우에는 API에서 false가 반환됩니다.

    // Check that ad is ready and that the placement is not capped 
    if ([self.interstitialAd isAdReady] && ![LPMInterstitialAd isPlacementCapped:placementName]) {
        [self.interstitialAd showAdWithViewController:self placementName:placementName];
    }
    
    • Light theme
    • Dark theme
    • Copy to clipboard

    플레이스먼트(지면)

    >레벨플레이 상에서 인터스티셜 광고의 플레이스먼트 및 송출 한도 및 빈도를 설정할 수 있습니다. 

    인터스티셜 광고용으로 플레이스먼트가 구성되어 있을 경우, showAd 메서드에 특정 플레이스먼트 명칭을 인자로 전달해 해당 플레이스먼트 설정으로 광고가 송출되도록 할 수 있습니다.

    // Check that ad is ready and that the placement is not capped
     if ([self.interstitialAd isAdReady] && ![LPMInterstitialAd isPlacementCapped:placementName]) {
        // Show ad with placement
        [self.interstitialAd showAdWithViewController:self placementName:@"PlacementName"];
    }
    • Light theme
    • Dark theme
    • Copy to clipboard

    인터스티셜 광고 연동 코드 전체 예제

    NS_ASSUME_NONNULL_BEGIN
    @interface InterstitialAdViewController () <LPMInterstitialAdDelegate>
    @property(nonatomic, strong) LPMInterstitialAd *interstitialAd;
    @end
    @implementation InterstitialAdViewController
    - (void)createInterstitialAd {
        self.interstitialAd = [[LPMInterstitialAd alloc] initWithAdUnitId:@"adUnitId"];
        self.interstitialAd.delegate = self;
    }
    - (void)loadInterstitialAd {
        // used to load or reload the ad
        [self.interstitialAd loadAd];
    }
    - (void)showInterstitialAd {
        if ([self.interstitialAd isAdReady]) {
            [self.interstitialAd showAdWithViewController:self placementName:NULL];
        }
    }
    - (void)showInterstitialAdWithPlacementName:(NSString *)placementName {
        // check that ad is ready and that the placement is not capped 
        if ([self.interstitialAd isAdReady] && ![LPMInterstitialAd isPlacementCapped:placementName]) {
            [self.interstitialAd showAdWithViewController:self placementName:placementName];
        }
    }
    #pragma mark - LPMInterstitialAdDelegate Methods
    - (void)didLoadAdWithAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didFailToLoadAdWithAdUnitId:(NSString *)adUnitId error:(NSError *)error {}
    - (void)didChangeAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didDisplayAdWithAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didFailToDisplayAdWithAdInfo:(LPMAdInfo *)adInfo error:(NSError *)error {}
    - (void)didClickAdWithAdInfo:(LPMAdInfo *)adInfo {}
    - (void)didCloseAdWithAdInfo:(LPMAdInfo *)adInfo {}
    @end
    NS_ASSUME_NONNULL_END
    • Light theme
    • Dark theme
    • Copy to clipboard

    레벨프레이 미디에이션 데모 앱

    연동 데모 앱은 인터스티셜 Ad Unit API를 활용해 인터스티셜 광고를 연동하는 방법에 대한 예시를 제공합니다.

    iOS 데모 앱 다운로드

    완료했습니다!
    이제 앱에서 인터스티셜 광고를 송출할 준비가 다 되었습니다. 연동 Test Suite를 사용해 연동이 올바르게 되었는지 확인하세요..


    다음에는 뭘 할까요?
    아래 연동 가이드를 따라 인터스티셜 광고를 제공할 수 있는 광고 네트워크를 미디에이션에 추가하거나, 다른 형태의 광고도 연동해 보세요: