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 EmpowerMobileAds
class 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 next
default:
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

StatusDescription
.initializingAd is loading
.readyAd is ready to show
.presentAd is currently displaying
.failedAd failed to load
.usedAd was shown and closed
.willLeaveUser clicked, leaving app

SwiftUI Integration

import SwiftUI
import EmpowerMobileAds
// MARK: - Interstitial Coordinator
class InterstitialCoordinator: NSObject, ObservableObject, AdStatusDelegate {
@Published var isReady = false
@Published var isShowing = false
private let zoneId: String
init(zoneId: String) {
self.zoneId = zoneId
super.init()
load()
}
func load() {
EMAManager.shared.loadInterstitial(zoneId: zoneId, delegate: self)
}
func show() {
guard isReady else { return }
// Get root view controller for SwiftUI
guard 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 = true
self.isShowing = false
case .present:
self.isShowing = true
case .used, .failed:
self.isReady = false
self.isShowing = false
self.load() // Reload
default:
break
}
}
}
}
// MARK: - Usage in SwiftUI View
struct HomeView: View {
@StateObject private var interstitial = InterstitialCoordinator(zoneId: "YOUR_ZONE_ID")
@State private var level = 1
var body: some View {
VStack {
Text("Level \(level)")
.font(.largeTitle)
Button("Complete Level") {
completeLevel()
}
.buttonStyle(.borderedProminent)
}
}
private func completeLevel() {
level += 1
// Show interstitial every 3 levels
if level % 3 == 0 && interstitial.isReady {
interstitial.show()
}
}
}

Interstitial Not Showing

  1. Ensure you're passing a valid view controller:
EMAManager.shared.showInterstitial(from: self) // 'self' must be a UIViewController
  1. Check ads are not disabled:
print("Ads disabled: \(EMASettings.shared.isAdsDisabled)")
  1. Enable debug logging:
EMASettings.shared.logLevel = .all