Skip to main content

Interstitial Placement

Interstitial placements display a fullscreen ad that the user can dismiss. Unlike other placement types, an interstitial is loaded in the background and shown at a natural transition point in your app.

Using Google Ad Manager, AdMob or Equativ?

This page covers the direct integration, where your app calls Teads SDK itself. If Google Ad Manager or AdMob requests your interstitials, follow the AdMob and Google Ad Manager interstitial guide instead. If you use Equativ Display SDK 8 mediation, follow the Equativ mediation guide.


Sample App

The official Teads SDK sample application includes working examples of this format. Use it for implementation examples and as a reference while you set up this placement.

Teads iOS Sample App on GitHub

Integration steps​

  1. Initialize Teads SDK once at app launch.
  2. Create and preload the placement before you need it.
  3. Handle events to know when the ad is ready, and to preload the next one after it closes.
  4. Show the ad at a natural transition point.

The examples below use a view controller. The same code works in any object that stays alive while the ad loads and shows.

Step 1: Initialize Teads SDK​

Call Teads.configure(with:) once at launch, in application(_:didFinishLaunchingWithOptions:) or your SwiftUI App initializer. See Installation for the full setup.

Step 2: Create and preload the placement​

Create the placement and call loadAd() ahead of the moment you want to show it, for example in viewDidLoad:

import TeadsSDK
import UIKit

class ArticleViewController: UIViewController {

// Keep a strong reference, or the placement is deallocated before it shows
private var interstitial: TeadsAdPlacementInterstitial?

override func viewDidLoad() {
super.viewDidLoad()

let config = TeadsAdPlacementInterstitialConfig(
articleUrl: URL(string: "https://example.com/article")!,
widgetId: "INT_APP_1", // Your widget ID
installationKey: "NANOWDGT01", // Your installation key
floorPrice: nil // Optional: minimum bid price in US dollars, e.g. 2.5
)

interstitial = TeadsAdPlacementInterstitial(config, delegate: self)
interstitial?.loadAd()
}
}

To try the integration before your own IDs are set up, use the values in Test PIDs and Configurations.

Keep both objects alive
  • Store the placement in a property, as above. A placement held only in a local variable is deallocated and never shows.
  • The placement holds its delegate weakly. The delegate must stay alive as long as the placement.
  • The delegate must conform to TeadsFullScreenEventsDelegate. A delegate that only conforms to TeadsAdPlacementEventsDelegate receives no events at all, and the SDK logs a warning.

Step 3: Handle events​

TeadsFullScreenEventsDelegate has two methods: one for ad events (loaded, failed, clicked) and one for fullscreen events (presented, dismissed).

The two events you need are .ready, which means the ad is loaded and can be shown, and .dismissed, which means the ad closed. An interstitial shows once, so call loadAd() again on .dismissed to preload the next ad on the same placement.

extension ArticleViewController: TeadsFullScreenEventsDelegate {

// Ad events
func adPlacement(
_ placement: TeadsAdPlacementIdentifiable?,
didEmitEvent event: TeadsAdPlacementEventName,
data: [String: Any]?
) {
switch event {
case .ready:
print("Interstitial ready to show")

case .failed:
// No fill, timeout, or "Ad expired". The placement resets, so call
// loadAd() again later if you still want an ad.
print("Interstitial failed: \(data?["reason"] as? String ?? "unknown")")

case .clicked:
// The SDK opens the click URL itself. Use this for tracking only.
break

default:
break
}
}

// Fullscreen events
func fullScreenPlacement(
_ placement: TeadsAdPlacementIdentifiable?,
didEmitEvent event: TeadsFullScreenEventName,
data: [String: Any]?
) {
switch event {
case .willPresent:
// Pause audio, video and timers
break

case .dismissed:
// Resume your app, then preload the next ad
interstitial?.loadAd()

default:
break
}
}
}

The SDK calls both methods on the main thread.

Swift 6 language mode

In Swift 6 mode, declare the conformance as extension ArticleViewController: @preconcurrency TeadsFullScreenEventsDelegate so that main-actor methods can satisfy the protocol.

Step 4: Show the ad​

At your transition point (end of an article, a level change, closing a screen), check isReady and call show(from:). If the ad is not ready, carry on without it. Don't wait for an ad to load while the user waits.

func showInterstitialIfReady() {
guard let interstitial, interstitial.isReady else { return }
interstitial.show(from: self)
}

If you pass nil to show(from:), the SDK presents from your app's top view controller. Calling it before the ad is ready emits .failed with reason "Ad is not ready".

Events at a glance​

WhenEventDelegate method
Ad filled (just before .ready).loadedadPlacement(_:didEmitEvent:data:)
Ad loaded and can be shown.readyadPlacement(_:didEmitEvent:data:)
Load failed, timed out, or ad expired.failedadPlacement(_:didEmitEvent:data:)
show(from:) called.willPresent, then .presentedfullScreenPlacement(_:didEmitEvent:data:)
Ad visible on screen.renderedadPlacement(_:didEmitEvent:data:)
Viewability threshold reached.viewedadPlacement(_:didEmitEvent:data:)
User tapped the ad.clickedadPlacement(_:didEmitEvent:data:)
User closed the ad.willDismiss, then .dismissedfullScreenPlacement(_:didEmitEvent:data:)

See Placement Events Listener for the full event reference and error handling guide.

Ad Cache TTL​

Once loaded, the ad must be shown within its cache TTL or it expires. The default TTL is 3600 seconds (1 hour), configurable server-side per widget. When the ad expires, .failed is emitted with reason: "Ad expired" and the placement resets. Call loadAd() again to fetch a fresh ad.

Cleanup​

To discard a loaded ad without showing it, call invalidate(), or set the property to nil:

interstitial?.invalidate()

// Or release it entirely
interstitial = nil

invalidate() is safe to call more than once, and the same placement can be loaded again with loadAd(). You don't need to call it after .dismissed: the placement already resets itself.

Best Practices​

Do not open the click URL

The SDK opens the click URL. Do not navigate in the .clicked handler or the browser will open twice. Use the event for tracking only.

Checklist​