전면 비디오 광고

1. 광고 요청

loadInterstitialVideo API를 호출하여 전면 비디오 광고를 요청합니다.

AdPopcornSSP.loadInterstitialVideo('your_app_key', 'your_placement_id');

2. 광고 노출

전면 비디오 광고가 정상적으로 로딩 완료 된 후, 광고 노출을 하고자 하는 시점에 showInterstitialVideo API를 호출합니다.

AdPopcornSSP.showInterstitialVideo('your_app_key', 'your_placement_id');

3. 이벤트 연동

광고 요청, 노출에 대한 결과 이벤트를 받는 설정을 진행할 수 있습니다. 원하는 이벤트만 연동하여 사용하면 됩니다. 해당 이벤트는 초기화 시, 등록한 event Listener로 넘어옵니다.

  • (전면 비디오) 지원되는 이벤트

Event
설명

OnInterstitialVideoAdLoaded (- placementId)

전면 비디오 광고 로드 성공

OnInterstitialVideoAdLoadFailed (- placementId, errorCode)

전면 비디오 광고 로드 실패

OnInterstitialVideoAdOpened (- placementId)

전면 비디오 광고 노출 성공

OnInterstitialVideoAdOpenFailed (- placementId)

전면 비디오 광고 노출 실패

OnInterstitialVideoAdClosed (- placementId)

전면 비디오 광고 닫기

4. 샘플 코드

const AdPopcornSSP = require('AdPopcornSSPPlugin');

cc.Class({
    extends: cc.Component,
    
    onLoad() {
        const ANDROID_APP_KEY = 'your_android_app_key';
        const IOS_APP_KEY = 'your_android_ios_key';
        
        const currentAppKey = cc.sys.os === cc.sys.OS_IOS ? IOS_APP_KEY : ANDROID_APP_KEY;
        if (cc.sys.os === cc.sys.OS_ANDROID || cc.sys.os === cc.sys.OS_IOS) {
            AdPopcornSSP.init(currentAppKey, (event, params) => this._onAdEvent(event, params));
            AdPopcornSSP.setLogEnable(true);
        }
    },
    _loadAds() {
        const ANDROID_APP_KEY = 'your_android_app_key';
        const IOS_APP_KEY = 'your_android_ios_key';
        
        if (cc.sys.os === cc.sys.OS_ANDROID) {
            AdPopcornSSP.loadInterstitialVideo(ANDROID_APP_KEY, 'placement_id');
        } else if (cc.sys.os === cc.sys.OS_IOS) {
            AdPopcornSSP.loadInterstitialVideo(IOS_APP_KEY, 'placement_id');
        }
    },
    _onAdEvent(event, params) {
        if (event === "AdPopcornSSPSDKDidInitialize") {
            this._loadAds();
        }
        else if(event === "OnInterstitialVideoAdLoaded"){
            if (cc.sys.os === cc.sys.OS_ANDROID) {
                AdPopcornSSP.showInterstitialVideo(ANDROID_APP_KEY, 'placement_id');
            } else if (cc.sys.os === cc.sys.OS_IOS) {
                AdPopcornSSP.showInterstitialVideo(IOS_APP_KEY, 'placement_id');
            }
        }        
    },
});

Last updated

Was this helpful?