> ## Documentation Index
> Fetch the complete documentation index at: https://docs.contentignite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Interstitial Ads

> Setting up Interstitial ads

Interstitial ads are full-screen ads that cover the interface of the app. They're typically displayed at natural transition points in the flow of the app.

## Initialising an ad

Start by initialising an instance of a `CIInterstitial` with the following parameters:

### Required:

* `placementID: String`: Unique ID for this Ad Placement provided by Content Ignite.
* `pageUrl: String?`: URL used for targeting for example if the ad is displayed in a section of the app which has an equivalent URL on the web.
* `eventListener: CIInterstitialEventListener`: This protocol allows you to respond to events related to the interstitial ad.

### Optional:

* `publisher`: Optional lambda to provide a fallback to your existing Ad implementation for this particular interstitial. This gives publishers full control over the use of the SDK and the rate at which this fallback is used can be controlled directly through the [Fusion](https://www.contentignite.com/fusion) platform.

```swift theme={null}
// Replace with your real placement ID
import UIKit
import CIMobileSDK

final class InterstitialDemoViewController: UIViewController {

    @MainActor
    private func loadAd() async {
        ...
        interstitial = CIInterstitial(
            placementID: "<PLACEMENT-ID>",
            pageUrl: "https://publisher.com/sport",
            eventListener: self
        )
        ...
    }
}
```

## Load the ad

When you are ready to load the ad, call `load()` on the ad instance:

```swift theme={null}
do {
    try await interstitial?.load()
} catch {
    print("Failed to load interstitial ad with error: \(error.localizedDescription)")
    ...
}
```

## Handling ad events

To listen and respond to events from an Interstitial ad, use the `CIInterstitialEventListener` protocol:

```swift theme={null}
extension InterstitialDemoViewController: CIInterstitialEventListener {
    func interstitialLoaded() {
        DispatchQueue.main.async { [weak self] in
            self?.uiState = .loaded
        }
    }

    func interstitialLoadFailed() {
        DispatchQueue.main.async { [weak self] in
            self?.uiState = .failed
        }
    }

    func interstitialDismissed() {
        DispatchQueue.main.async { [weak self] in
            self?.uiState = .initial
        }
    }
}
```

## Show the ad

When you are ready to display the ad, such as after a transition in the app flow, use the `show` method to display the ad:

```swift theme={null}
interstitial?.show()
```

See the full examples: [SPM](https://gitlab.com/content-ignite/content-ignite-mobile-sdk-ios-uikit/-/tree/main/Demos/CIMobileSDK-UIKit-SPM?ref_type=heads) | [CocoaPods](https://gitlab.com/content-ignite/content-ignite-mobile-sdk-ios-uikit/-/tree/main/Demos/CIMobileSDK-UIKit-CocoaPods?ref_type=heads).
