showInterstitial method
Shows a preloaded interstitial ad.
Returns true if the ad was shown, false if skipped due to:
- Ad not loaded yet
- Frequency cap not elapsed
- No interstitial ID configured
After showing, automatically preloads the next interstitial.
Implementation
Future<bool> showInterstitial() async {
_assertInitialized();
if (_config.interstitialId == null) return false;
if (_interstitialState != AdState.ready) return false;
if (!_interstitialFrequencyCap.canShow) return false;
_interstitialState = AdState.showing;
final adUnitId = _config.interstitialId!.resolved(
adType: AdType.interstitial,
);
// In production, this would call interstitialAd.show()
_interstitialFrequencyCap.recordImpression();
emitEvent(AdEvent(type: AdEventType.shown, adUnitId: adUnitId));
_interstitialState = AdState.idle;
_activeAdCount--;
// Auto-preload next
unawaited(loadInterstitial());
return true;
}