Interstitial Ad
1. 기본 요건
ADX Flutter SDK를 프로젝트에 추가합니다.
Interstitial Ad용으로 발급받은 ADX Ad Unit ID를 사용합니다.
광고를 요청하기 전에 SDK 초기화를 먼저 진행합니다.
SDK 초기화는 앱 실행 시 한 번만 호출하여 주시고, 광고 요청은 초기화가 완료된 후에 이뤄져야 합니다.
2. 구현
Android와 iOS 모두 배포된 경우 플랫폼 별로 발급받은 Ad Unit ID를 입력합니다.
필요한 콜백을 등록합니다.
AdxSdk.loadInterstitial()를 호출하여 광고를 로드합니다.광고 객체 해지시
AdxSdk.destroyInterstitial()를 호출합니다.
String adUnitId = Platform.isAndroid ? "<ANDROID_ADX_INTERSTITIAL_AD_UNIT_ID>" : "<IOS_ADX_INTERSTITIAL_AD_UNIT_ID>";
AdxSdk.setInterstitialListener(InterstitialAdListener(
onAdLoaded: (){
},
onAdError: (int errorCode){
},
onAdImpression: (){
},
onAdClicked: (){
},
onAdClosed: (){
},
onAdFailedToShow: (){
})
);
AdxSdk.loadInterstitial(adUnitId);광고가 로드가 되면
showInterstitial()를 호출하여 광고를 표출합니다.
bool isLoaded = (await AdxSdk.isInterstitialLoaded(adUnitId))!;
if (isLoaded) {
AdxSdk.showInterstitial(adUnitId);
}광고 객체 해지시
destroyInterstitial()를 호출합니다.
@override
void dispose() {
super.dispose();
AdxSdk.destroyInterstitial(adUnitId);
}3. Callback
특정 이벤트를 수신할 수 있습니다. 필요에 따라 구현해주세요.
class InterstitialAdListener {
void Function() onAdLoaded;
void Function(int errorCode) onAdError;
void Function() onAdImpression;
void Function() onAdClicked;
void Function() onAdClosed;
void Function() onAdFailedToShow;
InterstitialAdListener({
required this.onAdLoaded,
required this.onAdError,
required this.onAdImpression,
required this.onAdClicked,
required this.onAdClosed,
required this.onAdFailedToShow
});
}Last updated
Was this helpful?