---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://boost.yandex.com/doc/en/ad-monetization/dev/ios/interstitial.md
  - https://boost.yandex.com/doc/ru/ad-monetization/dev/ios/interstitial.md
  - href: en/ad-monetization/dev/ios/interstitial.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/en/llms.txt

# Interstitial ads

<!-- source: en/ad-monetization/dev/_includes/interstitial.md -->
Interstitial advertising is a full-screen ad format embedded within the app content during natural pauses, such as transitioning between game levels or completing a target action.
<!-- endsource: en/ad-monetization/dev/_includes/interstitial.md -->

When an app displays an interstitial ad, the user can either click through to the advertiser's site or close the ad and return to the app.

During interstitial ad impressions, the user's attention is fully focused on the ad, which results in a higher cost for such impressions.

{% cut "Appearance" %}

<img src="https://yastatic.net/s3/doc-binary/src/docs/support/mobile-ads/en/monetization/_images/interstitial-en-ex.png" width="200">

{% endcut %}

This guide will show how to integrate interstitial ads into iOS apps. Besides code samples and instructions, it contains format-specific recommendations and links to additional resources.


## Prerequisite {#pre}

<!-- source: en/ad-monetization/dev/_includes/pre-ios.md -->
1. Follow the SDK integration steps described under [Quick start](https://boost.yandex.com/doc/en/ad-monetization/dev/ios/quick-start.md).
2. First, you need to [initialize](https://boost.yandex.com/doc/en/ad-monetization/dev/ios/quick-start.md#init) the advertising SDK.
3. Make sure you're using the [latest version of the Yandex Mobile Ads SDK](https://boost.yandex.com/doc/en/ad-monetization/dev/platforms.md), and if you're using mediation, the latest version of the [unified build](https://boost.yandex.com/doc/en/ad-monetization/dev/platforms.md).
<!-- endsource: en/ad-monetization/dev/_includes/pre-ios.md -->

## Implementation {#implement}

Key steps for integrating interstitial ads:

- Create and configure the `InterstitialAdLoader` ad loader.
- Load the ad.
- Pass [additional settings](https://boost.yandex.com/doc/en/ad-monetization/dev/ios/target-adfox.md) if you're using Adfox.
- If needed, set a delegate for the ad object and implement the required `InterstitialAdDelegate` methods.
- Render the ad.

## Features of interstitial ad integration {#features}

1. All calls to Yandex Mobile Ads SDK methods must be made from the main thread.

2. We strongly advise against attempting to load a new ad immediately after a loading error. With completion handlers, this corresponds to the `.failure` case. With Swift Concurrency, it's the `catch` block. If you need to retry loading ads from the error handler, limit the number of retries. This helps prevent endless failed ad requests during network issues.

3. We recommend maintaining a strong reference to the ad and its loader throughout the lifespan of the screen where the ad interaction is taking place.

## Loading ads

To load interstitial ads, you need to create an instance of the `InterstitialAdLoader` class.

To load an ad, use the `loadAd(with:completion:)` method with a completion handler or the Swift Concurrency-powered `loadAd(with:)` method.

You can expand ad request parameters through `AdRequest`, by passing user interests, contextual page data, location, or other additional info. Adding extra context to ad requests can greatly improve ad relevance. To learn more, see [Ad targeting](https://boost.yandex.com/doc/en/ad-monetization/dev/ios/target.md).

The following example shows how to load an interstitial ad from the View Controller:

{% list tabs %}

- Swift Concurrency

  ```swift
  final class InterstitialViewController: UIViewController {
      private lazy var interstitialAdLoader = InterstitialAdLoader()
      private var interstitialAd: InterstitialAd?

      func loadAd() async {
          let request = AdRequest(adUnitID: "R-M-XXXXX-YY")
          do {
              let ad = try await interstitialAdLoader.loadAd(with: request)
              interstitialAd = ad
              ad.delegate = self
          } catch {
              // Load error
          }
      }
  }
  ```

- Completion handler

  ```swift
  final class InterstitialViewController: UIViewController {
      private lazy var interstitialAdLoader = InterstitialAdLoader()
      private var interstitialAd: InterstitialAd?

      func loadAd() {
          let request = AdRequest(adUnitID: "R-M-XXXXX-YY")
          interstitialAdLoader.loadAd(with: request) { [weak self] result in
              switch result {
              case .success(let ad):
                  self?.interstitialAd = ad
                  ad.delegate = self
              case .failure:
                  // Load error
                  break
              }
          }
      }
  }
  ```

{% endlist %}

## Displaying ads

Interstitial ads should be displayed during natural pauses in the app's usage. A good example of this would be impressions between game levels or when a user completes an action, such as downloading a file.

Once the interstitial ad loads, save and display it:

  ```swift
  final class InterstitialViewController: UIViewController {
      private lazy var interstitialAdLoader = InterstitialAdLoader()
      private var interstitialAd: InterstitialAd?

      func showAd() {
          interstitialAd?.show(from: self)
      }
  }
  ```

## Testing interstitial ad integration

### Using demo ad units for ad testing

<!-- source: en/ad-monetization/dev/_includes/test-ios-interstitial.md -->
Use test ads to check your ad integration and the app itself. To make sure that test ads are returned for each ad request, you can use a special demo ad placement ID.

Demo adUnitId: `demo-interstitial-yandex`.

{% note warning %}

Before publishing your app in the store, make sure to replace the demo placement ID with the real ID you obtained in the Boost interface.

{% endnote %}

For the list of all available demo ad placement IDs, see [Demo ad units for testing](https://boost.yandex.com/doc/en/ad-monetization/dev/ios/demo-blocks.md).
<!-- endsource: en/ad-monetization/dev/_includes/test-ios-interstitial.md -->

### Testing ad integration

<!-- source: en/ad-monetization/dev/_includes/test-integration-ios.md -->
You can test your ad integration using the native Console tool.

To view detailed logs, call the `YandexAds` class's `enableLogging` method.

```swift
YandexAds.enableLogging()
```

To view SDK logs, go to the Console tool and set `Subsystem = com.mobile.ads.ads.sdk`. You can filter logs by category or error level.

If you're having problems integrating ads, you'll get a detailed report on the issues and recommendations for how to fix them.

<img src= "https://yastatic.net/s3/doc-binary/src/dev/mobile-ads/common/integration-ios-2.png">
<!-- endsource: en/ad-monetization/dev/_includes/test-integration-ios.md -->

## Additional resources {#resources}

* <!-- source: en/ad-monetization/dev/_includes/github-pubdev-links.md -->
  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-sdk-ios/blob/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/Yandex/Interstitial/InterstitialAdViewController.swift).
  <!-- endsource: en/ad-monetization/dev/_includes/github-pubdev-links.md -->
