Interstitial Ads
Interstitial ads are full-screen ads that cover the interface. Display them at natural pause points in your app, such as between game levels or after completing a task.
Each ad format uses a Zone ID to identify the ad placement. Zone IDs are configured in the Empower dashboard.
Note: All ad status listeners are optional. The SDK handles ad loading and display automatically. Use listeners only if you need to track ad states for analytics, UI updates, or custom logic.
Quick Start
import EmpowerMobileAdsclass HomeViewController: UIViewController, AdStatusDelegate {override func viewDidLoad() {super.viewDidLoad()loadInterstitial()}func loadInterstitial() {EMAManager.shared.loadInterstitial(zoneId: "YOUR_INTERSTITIAL_ZONE_ID", delegate: self)}func showInterstitialIfReady() {if EMAManager.shared.isInterstitialReady() {EMAManager.shared.showInterstitial(from: self)} else {print("Interstitial not ready")}}func interstitialStatusChanged(_ manager: EmpowerInterstitialManager) {switch manager.status {case .ready:print("Interstitial ready to show")case .failed:print("Interstitial failed to load")case .used:loadInterstitial() // Preload nextdefault:break}}}
Loading Interstitials
Basic Loading
EMAManager.shared.loadInterstitial(zoneId: "YOUR_ZONE_ID", delegate: self)
With Custom Parameters
let customParams: [String: [String]] = ["level": ["5"],"game_mode": ["arcade"]]EMAManager.shared.loadInterstitial(zoneId: "YOUR_ZONE_ID",delegate: self,customParameters: customParams)
Showing Interstitials
Check Readiness First
Always verify the ad is ready before showing:
func showInterstitial() {if EMAManager.shared.isInterstitialReady() {EMAManager.shared.showInterstitial(from: self)} else {print("Interstitial not ready yet")// Optionally show without ad or wait}}
Status Handling
Status Flow
loadInterstitial() → .initializing → .ready → showInterstitial(from:) → .present → .used↓.failed (retry)
Status Values
| Status | Description |
|---|---|
.initializing | Ad is loading |
.ready | Ad is ready to show |
.present | Ad is currently displaying |
.failed | Ad failed to load |
.used | Ad was shown and closed |
.willLeave | User clicked, leaving app |
SwiftUI Integration
import SwiftUIimport EmpowerMobileAds// MARK: - Interstitial Coordinatorclass InterstitialCoordinator: NSObject, ObservableObject, AdStatusDelegate {@Published var isReady = false@Published var isShowing = falseprivate let zoneId: Stringinit(zoneId: String) {self.zoneId = zoneIdsuper.init()load()}func load() {EMAManager.shared.loadInterstitial(zoneId: zoneId, delegate: self)}func show() {guard isReady else { return }// Get root view controller for SwiftUIguard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,let rootVC = windowScene.windows.first?.rootViewController else { return }EMAManager.shared.showInterstitial(from: rootVC)}func interstitialStatusChanged(_ manager: EmpowerInterstitialManager) {DispatchQueue.main.async {switch manager.status {case .ready:self.isReady = trueself.isShowing = falsecase .present:self.isShowing = truecase .used, .failed:self.isReady = falseself.isShowing = falseself.load() // Reloaddefault:break}}}}// MARK: - Usage in SwiftUI Viewstruct HomeView: View {@StateObject private var interstitial = InterstitialCoordinator(zoneId: "YOUR_ZONE_ID")@State private var level = 1var body: some View {VStack {Text("Level \(level)").font(.largeTitle)Button("Complete Level") {completeLevel()}.buttonStyle(.borderedProminent)}}private func completeLevel() {level += 1// Show interstitial every 3 levelsif level % 3 == 0 && interstitial.isReady {interstitial.show()}}}
Interstitial Not Showing
- Ensure you're passing a valid view controller:
EMAManager.shared.showInterstitial(from: self) // 'self' must be a UIViewController
- Check ads are not disabled:
print("Ads disabled: \(EMASettings.shared.isAdsDisabled)")
- Enable debug logging:
EMASettings.shared.logLevel = .all