Mediation

Show Ads

Showing a Fullscreen Ad ๐Ÿ”—

The fullscreen APIs combine the existing Rewarded and Interstitial ad formats into a single integration experience.

Once you receive the fullscreen ad from the ad load request, you are ready to show it at your convenience.

  • // Set the delegate before showing the ad
    ad.delegate = self
    ad.show(with: <view controller>) { result in
        if let error = result.error {
            // Handle the error
        } else {
            // The ad was shown
        }
    }
    
    โ€”--------------
    Delegate Usage
    โ€”--------------
    
    func didRecordImpression(ad: FullscreenAd) {
        // Handle ad impression
    }
    
    func didClick(ad: FullscreenAd) {
        // Handle ad clicked
    }
    
    func didReward(ad: FullscreenAd) {
        // Handle ad reward
    }
    
    func didClose(ad: FullscreenAd, error: ChartboostMediationError?) {
        if let error = error {
            // Handle error
        } else {
            // Handle ad closed
        }
    }
    
    func didExpire(ad: FullscreenAd) {
        // Handle ad expired
    }
    
  • // Set the delegate before showing the ad
    ad.delegate = self;
    [ad showWith:<view controller> completion:^(CBMAdShowResult *result) {
        if (result.error != nil) {
            // Handle the error
        } else {
            // The ad was shown
        }
    }];
    
    โ€”--------------
    Delegate Usage
    โ€”--------------
    
    - (void)didRecordImpressionWithAd:(CBMFullscreenAd *)ad {
        // Handle ad impression
    }
    
    - (void)didClickWithAd:(CBMFullscreenAd *)ad {
        // Handle ad clicked
    }
    
    - (void)didRewardWithAd:(CBMFullscreenAd *)ad {
        // Handle ad reward
    }
    
    - (void)didCloseWithAd:(CBMFullscreenAd *)ad error:(CBMError *)error {
        if (error != nil) {
            // Handle error
        } else {
            // Handle ad closed
        }
    
    }
    
    - (void)didExpireWithAd:(CBMFullscreenAd *)ad {
        // Handle ad expired
    }
    

Showing Banner Ads ๐Ÿ”—

When youโ€™re ready to show a banner ad, you can check that itโ€™s ready to show and then display it like so:

  • if let bannerAd = bannerAd {
        view.addSubview(bannerAd)
    }
    
  • /// Banner ads are now automatically shown. All that you need to do
    /// is add it to the view hierarchy.
    [self.view addSubview:self.bannerAd];
    

If you enable auto-refresh for banner placement in the dashboard, then the Mediation SDK will apply that setting when the placement is shown.

Any auto-refresh changes made on the dashboard will take approximately one hour to take effect and the SDK must be rebooted in order to pick up the changes once theyโ€™re available.

Releasing Mediation Ads ๐Ÿ”—

To clear resources used by Mediation Ads, call reset() on a BannerAdView to clear the loaded ad and stop auto-refresh, or call invalidate() on a FullscreenAd to discard it from Chartboost Mediationโ€™s internal cache.

  • // Example of Releasing Banner Ads
    if let bannerAd = bannerAd {
        bannerAd.removeFromSuperview()
        self.bannerAd = nil
        self.bannerConstraints = nil
    }
    
  • // Example of Releasing Banner Ads
    if (self.bannerAd) {
          [self.bannerAd removeFromSuperview];
          self.bannerAd = nil;
          self.bannerConstraints = nil;
    }