전면 비디오 광고
1. 인스턴스 생성
AppKey와placementId를 파라미터로 넘겨주고 전면 비디오 광고 관련 인스턴스를 생성한다.
RNAdPopcornInterstitialVideoAdModule.createInstance('YOUR_APP_KEY', 'PLACEMENT_ID');
2. 광고 요청
전면 비디오 광고 노출을 원하는 시점에 loadAd()
API를 호출하여 서버에 광고를 요청합니다.
RNAdPopcornInterstitialVideoAdModule.loadAd('PLACEMENT_ID');
3. 광고 노출
전면 비디오광고 노출 시점에 showAd()
API를 추가하여 광고를 노출합니다.
RNAdPopcornInterstitialVideoAdModule.showAd('PLACEMENT_ID');
4. 이벤트 연동
componentDidMount() {
...
const eventEmitter = new NativeEventEmitter();
eventEmitter.addListener('OnInterstitialVideoAdLoaded', (event) => {
console.log('OnInterstitialVideoAdLoaded event : ' + event.placementId);
}
);
...
}
이벤트
설명
OnInterstitialVideoAdLoaded
전면 비디오 로딩 성공
ㄴevent.placementId
전면 비디오 로딩 성공한 지면 키
OnInterstitialVideoAdLoadFailed
전면 비디오 로딩 실패
ㄴevent.placementId
전면 비디오 로딩 실패한 지면 키
ㄴevent.errorCode
전면 비디오 로딩 실패 에러코드
ㄴevent.errorMessage
전면 비디오 로딩 실패 에러 메시지
OnInterstitialVideoAdOpened
전면 비디오 노출
ㄴevent.placementId
노출된 전면 비디오 광고 지면 키
OnInterstitialVideoAdOpenFalied
전면 비디오 노출 실패
ㄴevent.placementId
노출 실패한 전면 비디오 광고 지면 키
OnInterstitialVideoAdClosed
전면 비디오 닫기
ㄴevent.placementId
전면 비디오 광고 닫은 지면 키
OnInterstitialVideoAdClicked
전면 비디오 클릭
ㄴevent.placementId
전면 비디오 광고 클릭한 지면 키
5. 샘플 코드
import React, { useEffect } from 'react';
import {
NativeModules,
NativeEventEmitter
} from 'react-native';
const RNAdPopcornInterstitialVideoAdModule= NativeModules.RNAdPopcornInterstitialVideoAdModule;
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
RNAdPopcornSSPModule.init();
RNAdPopcornInterstitialVideoAdModule.createInstance('YOUR_APP_KEY', 'PLACEMENT_ID');
RNAdPopcornInterstitialVideoAdModule.loadAd('PLACEMENT_ID');
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
</ScrollView>
</SafeAreaView>
);
}
componentDidMount() {
...
const eventEmitter = new NativeEventEmitter();
eventEmitter.addListener('OnInterstitialVideoAdLoaded', (event) => {
console.log('OnInterstitialVideoAdLoaded event : ' + event.placementId);
RNAdPopcornInterstitialVideoAdModule.showAd(event.placementId);
}
);
...
}
Last updated
Was this helpful?