Mediation

Show Ads

Showing a Fullscreen Ad πŸ”—

The new gullscreen 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: ChartboostMediationFullscreenAd) {
        // Handle ad impression
    }
    
    func didClick(ad: ChartboostMediationFullscreenAd) {
        // Handle ad clicked
    }
    
    func didReward(ad: ChartboostMediationFullscreenAd) {
        // Handle ad reward
    }
    
    func didClose(ad: ChartboostMediationFullscreenAd, error: ChartboostMediationError?) {
        if let error = error {
            // Handle error
        } else {
            // Handle ad closed
        }
    }
    
    func didExpire(ad: ChartboostMediationFullscreenAd) {
        // Handle ad expired
    }
    
  • // Set the delegate before showing the ad
    ad.delegate = self;
    [ad showWith:<view controller> completion:^(ChartboostMediationAdShowResult *result) {
        if (result.error != nil) {
            // Handle the error
        } else {
            // The ad was shown
        }
    }];
    
    β€”--------------
    Delegate Usage
    β€”--------------
    
    - (void)didRecordImpressionWithAd:(id<ChartboostMediationFullscreenAd>)ad {
        // Handle ad impression
    }
    
    - (void)didClickWithAd:(id<ChartboostMediationFullscreenAd>)ad {
        // Handle ad clicked
    }
    
    - (void)didRewardWithAd:(id<ChartboostMediationFullscreenAd>)ad {
        // Handle ad reward
    }
    
    - (void)didCloseWithAd:(id<ChartboostMediationFullscreenAd>)ad error:(ChartboostMediationError *)error {
        if (error != nil) {
            // Handle error
        } else {
            // Handle ad closed
        }
    
    }
    
    - (void)didExpireWithAd:(id<ChartboostMediationFullscreenAd>)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, you can use the destroy method associated with the respective Mediation Ad you have used.

  • // 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;
    }