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

# Interstitial Ads

> Implement interstitial ads in your iOS app.

## Interstitial Ad Format

Full-screen ads that cover the entire app interface. Includes both image and video ads (video more common), typically skippable after 5 seconds.

<img src="https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/common-img/ad-formats-en/interstitial-example-image.png?fit=max&auto=format&n=j3-znW7LKrbpP3mb&q=85&s=7404e29ead548d55d8d587336f8721f9" alt="Interstitial Example Image Pn" title="Interstitial Example Image Pn" style={{ width:"41%" }} width="1080" height="2336" data-path="sdk-integration/common-img/ad-formats-en/interstitial-example-image.png" />

### How It Works

<img src="https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/common-img/ad-formats-en/interstitial-example-gif.gif?s=9f37cff5b366f1e05211b0d177b3926b" alt="Interstitial Example Gif Gi" title="Interstitial Example Gif Gi" style={{ width:"41%" }} width="240" height="518" data-path="sdk-integration/common-img/ad-formats-en/interstitial-example-gif.gif" />

***

## Ad Unit Setup

Configure your ad unit using the `ad unit ID` issued from the dashboard.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let interstitialUnit = DaroAdUnit(unitId: "your_interstitial_unit_id")
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objc theme={null}
    // In Objective-C, unitId is passed directly during initialization
    NSString *interstitialUnitId = @"your_interstitial_unit_id";
    ```
  </Tab>
</Tabs>

## Ad Implementation

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    class ExampleViewController: UIViewController {
        private var daroInterstitialAd: DaroInterstitialAd? = nil
        let daroInterstitialLoader = DaroInterstitialAdLoader(unit: interstitialUnit)

        override func viewDidLoad() {
            super.viewDidLoad()
            setupInterstitialAd()
        }

        private func setupInterstitialAd() {
            // Ad load success listener
            daroInterstitialLoader.listener.onAdLoadSuccess = { [weak self] ad, adInfo in
                print("[DARO] Listener Interstitial Ad loaded: \(ad) \(adInfo)")
                self?.showAd(ad: ad)
            }

            // Ad click listener
            daroInterstitialLoader.listener.onAdClicked = { adInfo in
                print("[DARO] Listener Interstitial Ad clicked: \(adInfo)")
            }

            // Ad impression listener
            daroInterstitialLoader.listener.onAdImpression = { adInfo in
                print("[DARO] Listener Interstitial Ad impression: \(adInfo)")
            }

            // Ad load fail listener
            daroInterstitialLoader.listener.onAdLoadFail = { error in
                print("[DARO] Listener Interstitial Ad failed: \(error)")
            }
            daroInterstitialLoader.loadAd()
        }

        private func showAd(ad: DaroInterstitialAd) {
            self.daroInterstitialAd = ad

            // Ad show success listener
            self.daroInterstitialAd?.interstitialListener.onShown = { adInfo in
                print("[DARO] Listener Interstitial Ad shown: \(adInfo)")
            }

            // Ad dismiss listener
            self.daroInterstitialAd?.interstitialListener.onDismiss = { adInfo in
                print("[DARO] Listener Interstitial Ad dismissed: \(adInfo)")
            }

            // Ad show fail listener
            self.daroInterstitialAd?.interstitialListener.onFailedToShow = { adInfo, error in
                print("[DARO] Listener Interstitial Ad failed to show: \(adInfo) \(error)")
            }
            showInterstitialAd()
        }

        private func showInterstitialAd() {
            daroInterstitialAd?.show(viewController: self)
        }
    }
    ```
  </Tab>

  <Tab title="Objective-C">
    **1. Adopt the delegate protocol in your header file:**

    ```objc theme={null}
    @interface ExampleViewController () <DaroObjCInterstitialAdDelegate>
    @property (nonatomic, strong) DaroObjCInterstitialAd *interstitialAd;
    @end
    ```

    **2. Setup and load interstitial ad:**

    ```objc theme={null}
    - (void)setupInterstitialAd {
        self.interstitialAd = [[DaroObjCInterstitialAd alloc]
            initWithAdUnitId:@"your_interstitial_unit_id"];
        self.interstitialAd.delegate = self;

        // Load ad
        [self.interstitialAd load];
    }
    ```

    **3. Implement delegate methods:**

    ```objc theme={null}
    #pragma mark - DaroObjCInterstitialAdDelegate

    - (void)interstitialAdDidLoad:(DaroObjCInterstitialAd *)ad
                           adInfo:(DaroObjCAdInfo *)adInfo {
        NSLog(@"[DARO] Interstitial ad loaded - Unit: %@", adInfo.adUnitId);
    }

    - (void)interstitialAdDidFail:(DaroObjCInterstitialAd *)ad
                            toLoad:(NSError *)error {
        NSLog(@"[DARO] Failed to load: %@", error.localizedDescription);
    }

    - (void)interstitialAdDidShow:(DaroObjCInterstitialAd *)ad
                           adInfo:(DaroObjCAdInfo *)adInfo {
        NSLog(@"[DARO] Interstitial ad shown");
    }

    - (void)interstitialAdDidFail:(DaroObjCInterstitialAd *)ad
                            toShow:(DaroObjCAdInfo *)adInfo
                             error:(NSError *)error {
        NSLog(@"[DARO] Failed to show: %@", error.localizedDescription);
    }

    - (void)interstitialAdDidClick:(DaroObjCInterstitialAd *)ad
                            adInfo:(DaroObjCAdInfo *)adInfo {
        NSLog(@"[DARO] Interstitial ad clicked");
    }

    - (void)interstitialAdDidRecordImpression:(DaroObjCInterstitialAd *)ad
                                       adInfo:(DaroObjCAdInfo *)adInfo {
        NSLog(@"[DARO] Impression recorded");
    }

    - (void)interstitialAdDidDismiss:(DaroObjCInterstitialAd *)ad
                              adInfo:(DaroObjCAdInfo *)adInfo {
        NSLog(@"[DARO] Interstitial ad dismissed");
    }
    ```

    **4. Show ad:**

    ```objc theme={null}
    - (void)showInterstitialAd {
        if (self.interstitialAd.isReady) {
            [self.interstitialAd showFrom:self];
        } else {
            NSLog(@"[DARO] Ad is not ready to show");
        }
    }
    ```
  </Tab>
</Tabs>

***

## Troubleshooting: Ad Close Button Overlap Issue

<Warning>
  When displaying interstitial ads using the DARO iOS SDK, some ad creatives may visually overlap with the top Safe Area or Status Bar.
  The following guide shows how to hide the Status Bar only while the ad is displayed and restore it once the ad is dismissed.
</Warning>

<Tabs>
  <Tab title="Swift">
    **1. Add status bar control properties to your ViewController:**

    ```swift theme={null}
    class ExampleViewController: UIViewController {
        private var isAdShowing = false

        override var prefersStatusBarHidden: Bool {
            return isAdShowing
        }

        override var childForStatusBarHidden: UIViewController? {
            return presentedViewController
        }
    }
    ```

    **2. Hide status bar before showing ad and restore in callbacks:**

    ```swift theme={null}
    private func showAd(ad: DaroInterstitialAd) {
        self.daroInterstitialAd = ad

        self.daroInterstitialAd?.interstitialListener.onShown = { [weak self] adInfo in
            print("[DARO] Interstitial Ad shown")
        }

        self.daroInterstitialAd?.interstitialListener.onDismiss = { [weak self] adInfo in
            self?.isAdShowing = false
            self?.setNeedsStatusBarAppearanceUpdate()
        }

        self.daroInterstitialAd?.interstitialListener.onFailedToShow = { [weak self] adInfo, error in
            self?.isAdShowing = false
            self?.setNeedsStatusBarAppearanceUpdate()
        }

        // Hide status bar just before show()
        isAdShowing = true
        setNeedsStatusBarAppearanceUpdate()
        daroInterstitialAd?.show(viewController: self)
    }
    ```
  </Tab>

  <Tab title="Objective-C">
    **1. Add property to header file:**

    ```objc theme={null}
    @interface ExampleViewController ()
    @property (nonatomic, assign) BOOL adShowing;
    @end
    ```

    **2. Override status bar control methods:**

    ```objc theme={null}
    - (BOOL)prefersStatusBarHidden {
        return self.adShowing;
    }

    - (UIViewController *)childViewControllerForStatusBarHidden {
        return self.presentedViewController;
    }
    ```

    **3. Hide before showing ad and restore in callbacks:**

    ```objc theme={null}
    - (void)showInterstitialAd {
        // Hide status bar just before show()
        self.adShowing = YES;
        [self setNeedsStatusBarAppearanceUpdate];

        [self.interstitialAd showFrom:self];
    }

    // Restore on dismiss
    - (void)interstitialAdDidDismiss:(DaroObjCInterstitialAd *)ad
                              adInfo:(DaroObjCAdInfo *)adInfo {
        self.adShowing = NO;
        [self setNeedsStatusBarAppearanceUpdate];
    }

    // Restore on show failure
    - (void)interstitialAdDidFail:(DaroObjCInterstitialAd *)ad
                            toShow:(DaroObjCAdInfo *)adInfo
                             error:(NSError *)error {
        self.adShowing = NO;
        [self setNeedsStatusBarAppearanceUpdate];
    }
    ```
  </Tab>
</Tabs>
