Load Ads
Creating Interstitial & Rewarded Ads
To show an ad, first declare a variable to hold a reference to either the Interstitial or Rewarded Mediation Ad. Supply the corresponding Placement Name you set up on your dashboard as the argument for each of these functions:
//Helium Interstitial Ad
private HeliumInterstitialAd interstitialAd;
//Helium Rewarded Ad
private HeliumRewardedAd rewardedAd;
this.interstitialAd = HeliumSdk.getInterstitialAd(PLACEMENT_INTERSTITIAL);
this.rewardedAd = HeliumSdk.getRewardedAd(PLACEMENT_REWARDED);
Loading Interstitial & Rewarded Ads
Create an instance for each Placement Name you want to use. Make the following call to load the ad:
this.interstitialAd.load();
this.rewardedAd.load();
You can implement delegates in your class to receive notifications about the success or failure of the ad loading process for both Interstitial and Rewarded formats. See section Delegate Usage for more details.
Creating Banner Ads
To show a banner ad, first declare a variable to hold a reference to the Banner Mediation Ad. Supply the corresponding Placement Name and the Banner Size.
Note
The following banner sizes can be passed down. Some partners may not fill for some banner sizes.
Banner Enum | Dimensions (Width x Height) |
---|---|
Standard | (320 x 50) |
Medium | (300 x 250) |
Leaderboard | (728 x 90) |
//Helium Banner Ad
private HeliumBannerAd _bannerAd;
// if null, create a new banner ad with desired parameters
if (_bannerAd == null) {
var placement = "MY_BANNER_PLACEMENT"
var size = HeliumBannerAdSize.Standard;
bannerAd = HeliumSDK.GetBannerAd(placement, size);
}
//Helium Banner Ad
private HelliumBannerAd bannerAd;
if (this.bannerAd == null) {
/*
The following Banner enum Sizes can be passed down:
HeliumBannerAdSize.Standard
HeliumBannerAdSize.MediumRect
HeliumBannerAdSize.Leaderboard
*/
HeliumBannerAdSize BANNER_SIZE = HeliumBannerAdSize.Standard;
this.bannerAd = HeliumSdk.getBannerAd(PLACEMENT_BANNER, BANNER_SIZE);
}
Loading Banner Ads
You will need to create an instance for each Placement Name you want to use. Make the following call to load the ad:
if (_bannerAd != null) {
// specify location on load
_bannerAd.Load(HeliumBannerAdScreenLocation.BottomCenter)
}
this.bannerAd.load();
You can implement delegates in your class to receive notifications about the success or failure of the ad loading process for banner formats. See section Delegate Usage for more details.
Showing Banner Ads
In Mediation 3.0 and above, banners are automatically shown. Trigger visibility using the following setting:
// Banner ads are now automatically shown.
// Visibility can be toggled with
_bannerAd.SetVisibility(false/true);
Clearing Loaded Ads
You may need to clear loaded ads on existing placements to request another ad (i.e. for an in-house programmatic auction). To do this:
_interstitialAd.ClearLoaded();
_rewardedAd.ClearLoaded();
// This will clear the currently showing ad and any cached
// ad that was loaded for auto refresh.
_bannerAd.ClearLoaded();
this.interstitialAd.clearLoaded();
this.rewardedAd.clearLoaded();
this.bannerAd.clearLoaded();
The clearLoaded
API returns a boolean and indicates if the ad object has been cleared and is ready for another load call.
Updated 4 days ago