Show Ads
Showing Interstitial and Rewarded Ads
When you’re ready to show an ad, you can check that it’s ready to show and then display it like so:
if let interstitialAd = interstitialAd {
if interstitialAd.readyToShow() {
interstitialAd.show(with: self)
} else {
// When there’s no Mediation Ad ready to show immediately,
// fall through to your chosen backup behavior.
interstitialAd.load()
}
}
if let rewardedAd = rewardedAd {
if rewardedAd.readyToShow() {
rewardedAd.show(with: self)
} else {
// When there’s no Mediation Ad ready to show immediately,
// fall through to your chosen backup behavior.
rewardedAd.load()
}
}
if ([self.interstitialAd readyToShow]) {
[self.interstitialAd showAdWithViewController:self];
}
else {
//when there’s no Mediation Ad ready to show immediately,
//fall through to your chosen backup behavior.
[self.interstitialAd loadAd];
}
if ([self.rewardedAd readyToShow]) {
[self.rewardedAd showAdWithViewController:self];
}
else {
//when there’s no Mediation Ad ready to show immediately,
//fall through to your chosen backup behavior.
[self.rewardedAd loadAd];
}
If the readyToShow
response comes back negative, this can be a good opportunity to gracefully recover by making a new attempt to load a Mediation Ad as well as implement any fall through behavior you desire.
You can implement CHBHeliumInterstitialAdDelegate
or CHBHeliumRewardedAdDelegate
in your class to receive notifications about the lifecycle of the ad display process. See section Delegate Usage for more details.
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;
}
Updated 4 months ago