# Interstitial

## Integration

Unlike banners, interstitials can only be integrated with code. Below we show a simple example to understand how it works:

{% tabs %}
{% tab title="Swift" %}

```swift
import UIKit
import WortiseSDK

class ViewController: UIViewController {

    private var interstitialAd: WAInterstitialAd!

    override func viewDidLoad() {
        super.viewDidLoad()
        ...
        interstitialAd = WAInterstitialAd(adUnitId: "test-interstitial")
        interstitialAd.loadAd()
    }

    override func willMove(toParent controller: UIViewController?) {
        super.willMove(toParent: controller)
        ...
        interstitialAd.destroy()
    }

    func showInterstitial() {
        if interstitialAd.isAvailable {
            interstitialAd.showAd(from: self)
        }
    }
}
```

{% endtab %}
{% endtabs %}

## **Delegate configuration**

Like occurs with banners, a listener can be set to receive the events that happen during the interstitial lifecycle. For this, it is needed to implement the `WAInterstitialDelegate` interface just as shown in the example below:

{% tabs %}
{% tab title="Swift" %}

```swift
extension ViewController : WAInterstitialDelegate {
    
    func didClick(interstitialAd: WAInterstitialAd) {
        // Invoked when the ad has been clicked
    }

    func didDismiss(interstitialAd: WAInterstitialAd) {
        // Invoked when the ad has been dismissed
    }
    
    func didFailToLoad(interstitialAd: WAInterstitialAd, error: WAAdError) {
        // Invoked when the ad could not be loaded
        // (because of an error or no fill)
    }

    func didFailToShow(interstitialAdenAd: WAInterstitialAd, error: WAAdError) {
        // Invoked when the ad could not be shown
    }

    func didImpress(interstitialAd: WAInterstitialAd) {
        // Invoked when the ad has generated an impression
    }

    func didLoad(interstitialAd: WAInterstitialAd) {
        // Invoked when the ad has been loaded
    }
    
    func didPayRevenue(interstitialAd: WAInterstitialAd, data: WARevenuedata) {
        // Invoked when the ad has generated revenue
    }
 
    func didShow(interstitialAd: WAInterstitialAd) {
        // Invoked when the ad has been shown
    }
}
```

Once the interface is implemented, the delegate is assigned to the ad instance:

```swift
interstitialAd.delegate = self
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wortise.com/en/ios-sdk/sdk-integration/interstitial.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
