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.
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.
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.
Integration steps
- Initialize Teads SDK once at app launch.
- Create and preload the placement before you need it.
- Handle events to know when the ad is ready, and to preload the next one after it closes.
- 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:
- Swift
- Objective-C
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()
}
}
#import <TeadsSDK/TeadsSDK-Swift.h>
@interface ArticleViewController : UIViewController <TeadsFullScreenEventsDelegate>
// Keep a strong reference, or the placement is deallocated before it shows
@property (nonatomic, strong) TeadsAdPlacementInterstitial *interstitial;
@end
@implementation ArticleViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.interstitial = [[TeadsAdPlacementInterstitial alloc]
initWithArticleUrl:[NSURL URLWithString:@"https://example.com/article"]
widgetId:@"INT_APP_1" // Your widget ID
installationKey:@"NANOWDGT01" // Your installation key
floorPrice:0 // Optional floor price in whole US dollars; 0 = no floor. Objective-C takes an integer — use the Swift config for decimal values
delegate:self];
[self.interstitial loadAd];
}
@end
To try the integration before your own IDs are set up, use the values in Test PIDs and Configurations.
- 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 toTeadsAdPlacementEventsDelegatereceives 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.
- Swift
- Objective-C
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
}
}
}
// Inside @implementation ArticleViewController
// Ad events
- (void)adPlacement:(id<TeadsAdPlacementIdentifiable>)placement
didEmitEvent:(TeadsAdPlacementEventName)event
data:(NSDictionary<NSString *, id> *)data {
switch (event) {
case TeadsAdPlacementEventNameReady:
NSLog(@"Interstitial ready to show");
break;
case TeadsAdPlacementEventNameFailed:
// No fill, timeout, or "Ad expired". The placement resets, so call
// loadAd again later if you still want an ad.
NSLog(@"Interstitial failed: %@", data[@"reason"] ?: @"unknown");
break;
case TeadsAdPlacementEventNameClicked:
// The SDK opens the click URL itself. Use this for tracking only.
break;
default:
break;
}
}
// Fullscreen events
- (void)fullScreenPlacement:(id<TeadsAdPlacementIdentifiable>)placement
didEmitEvent:(TeadsFullScreenEventName)event
data:(NSDictionary<NSString *, id> *)data {
switch (event) {
case TeadsFullScreenEventNameWillPresent:
// Pause audio, video and timers
break;
case TeadsFullScreenEventNameDismissed:
// Resume your app, then preload the next ad
[self.interstitial loadAd];
break;
default:
break;
}
}
The SDK calls both methods on the main thread.
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.
- Swift
- Objective-C
func showInterstitialIfReady() {
guard let interstitial, interstitial.isReady else { return }
interstitial.show(from: self)
}
- (void)showInterstitialIfReady {
if (self.interstitial.isReady) {
[self.interstitial showFrom: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
| When | Event | Delegate method |
|---|---|---|
Ad filled (just before .ready) | .loaded | adPlacement(_:didEmitEvent:data:) |
| Ad loaded and can be shown | .ready | adPlacement(_:didEmitEvent:data:) |
| Load failed, timed out, or ad expired | .failed | adPlacement(_:didEmitEvent:data:) |
show(from:) called | .willPresent, then .presented | fullScreenPlacement(_:didEmitEvent:data:) |
| Ad visible on screen | .rendered | adPlacement(_:didEmitEvent:data:) |
| Viewability threshold reached | .viewed | adPlacement(_:didEmitEvent:data:) |
| User tapped the ad | .clicked | adPlacement(_:didEmitEvent:data:) |
| User closed the ad | .willDismiss, then .dismissed | fullScreenPlacement(_: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:
- Swift
- Objective-C
interstitial?.invalidate()
// Or release it entirely
interstitial = nil
[self.interstitial invalidate];
// Or release it entirely
self.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
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
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
- ✅ Comply with app-ads.txt
- ✅ Implement proper error handling
- ✅ Test with the PIDs in Test PIDs and Configurations