interstitial ads는 앱의 인터페이스를 일시적으로 가리는 전체 화면 또는 전체 페이지 광고입니다. 일반적으로 게임에서 레벨을 완료한 후나 주요 뷰 사이를 이동할 때와 같이 자연스러운 일시 중지 또는 전환 시점에 표시됩니다.
다음 섹션에서는 interstitial ad를 로드하고 표시하는 방법을 보여줍니다.
다음 코드는 리스너를 연결하고 첫 번째 interstitial을 로드하는 방법을 보여줍니다.
final String _interstitial_ad_unit_ID = Platform.isAndroid ? "«Android-ad-unit-ID»" : "«iOS-ad-unit-ID»";
const int _maxExponentialRetryCount = 6;
var _interstitialRetryAttempt = 0;
void initializeInterstitialAds() {
AppLovinMAX.setInterstitialListener(InterstitialListener(
onAdLoadedCallback: (ad) {
// Interstitial ad is ready to show. AppLovinMAX.isInterstitialReady(_interstitial_ad_unit_ID) now returns 'true'.
print('Interstitial ad loaded from ' + ad.networkName);
// Reset retry attempt
_interstitialRetryAttempt = 0;
},
onAdLoadFailedCallback: (adUnitId, 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).
_interstitialRetryAttempt = _interstitialRetryAttempt + 1;
if (_interstitialRetryAttempt > _maxExponentialRetryCount) return;
int retryDelay = pow(2, min(_maxExponentialRetryCount, _interstitialRetryAttempt)).toInt();
print('Interstitial ad failed to load with code ' + error.code.toString() + ' - retrying in ' + retryDelay.toString() + 's');
Future.delayed(Duration(milliseconds: retryDelay * 1000), () {
AppLovinMAX.loadInterstitial(_interstitial_ad_unit_ID);
});
},
onAdDisplayedCallback: (ad) {
⋮
},
onAdDisplayFailedCallback: (ad, error) {
⋮
},
onAdClickedCallback: (ad) {
⋮
},
onAdHiddenCallback: (ad) {
⋮
},
));
// Load the first interstitial.
AppLovinMAX.loadInterstitial(_interstitial_ad_unit_ID);
}
권장 사항: Interstitial ads 표시하기
interstitial ad를 표시하려면 showInterstitial()을 호출하세요.
bool isReady = (await AppLovinMAX.isInterstitialReady(_interstitial_ad_unit_ID))!;
if (isReady) {
AppLovinMAX.showInterstitial(_interstitial_ad_unit_ID);
}