> ## 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 `CIInterstitialAd` with the following parameters:

### Required:

* `placementID: String`: Unique ID for this Ad Placement provided by Content Ignite.
* `eventListener: CIInterstitialEventListener`: This interface allows you to respond to events related to the interstitial ad.
* `targeting: Map<String, List<String>>`: Pass custom key-value pairs to ad requests.
* `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.

### 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.

```kotlin theme={null}
val eventListener = object : CIInterstitialEventListener {
    override fun interstitialDismissed() {
        _state.update { UIState.Default }
    }

    override fun interstitialLoadFailed() {
        _state.update { UIState.Failed }
    }

    override fun interstitialLoaded() {
        _state.update { UIState.Loaded }
    }
}

val interstitial = CIInterstitialAd(
    context = appContext,
    placementID = "<PLACEMENT-ID>",
    targeting = mapOf("segment" to listOf("health", "fitness")),
    eventListener = eventListener,
    pageUrl = "https://example.com/sport"
)
```

## Show the ad

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

```kotlin theme={null}
when (val ad = interstitial) {
    null -> _state.update { UIState.Failed }
    else -> ad.show(activity)
}
```

See the full examples: [Compose](https://gitlab.com/content-ignite/content-ignite-mobile-sdk-android/-/tree/main/samples/Compose/kotlin-compose-sample?ref_type=heads) | [View-based](https://gitlab.com/content-ignite/content-ignite-mobile-sdk-android/-/tree/main/samples/View-Based/kotlin-views-sample?ref_type=heads).
