Skip to main content
Version: 5.x.x

Unity LevelPlay

This guide shows you how to integrate our BlueStack mediation adapter of Unity LevelPlay with your current Android app and set up additional request parameters.

Release notes can be found here

Supported Ad Formats

  • Banner
  • Rewarded
  • Interstitial

Requirements

  • Android SDK 4.4 (API level 19) or later
  • Google Play Services 21.1.0 or later
  • Iron Source Mediation SDK 8.6.0 or higher

Unity LevelPlay Configuration

When in the Unity LevelPlay dashboard, under your app in the left panel navigate to Setup -> Networks, in the right panel at the bottom of the page you have the option to Add custom network.

img.png

You'll be directed to a new page.

Please enter 15c080481 in the Network Key input field and click Confirm Key. After confirmation, it will show the network name Improve Digital. Then click Save.

img.png

Custom Network Key: 15c080481
Custom Network Name: Improve Digital

Congratulations!!! You have added our network successfully.

Next, navigate to Setup -> Instances in the left panel, and click Improve Digital in the right panel.

img.png

This will navigate you to a new page where you will add new instances for different types of ads.

img.png

Click on the button **+ Add Instance at the bottom in the right panel, select the type of ad you want to add.

img.png

Enter Instance Name, placementId, Rate, and select target Mediation Groups. Also, add your appId at the top in the right panel and click Save.

Note: The placementIds will be provided by the Azerion team. And Rate is used for IronSource reporting only; it will not reflect the actual money. Rates can be aligned with the Azerion team as well.

img.png

Ad Formats

Supported LevelPlayBannerAdViewListener Callback

// Indicates that a banner ad was loaded successfully 
@Override
public void onAdLoaded(LevelPlayAdInfo adInfo) {
// Handle banner ad loaded
}

// The banner ad failed to load. Use LevelPlayAdError ErrorTypes (No Fill / Other)
@Override
public void onAdLoadFailed(LevelPlayAdError error) {
// Handle banner ad load failure
}

// Indicates an ad was clicked
@Override
public void onAdClicked(LevelPlayAdInfo adInfo) {
// Handle banner ad click
}

Initialization and Load Banner Ad

LevelPlayBannerAdView bannerAd = new LevelPlayBannerAdView(this, "YOUR_BANNER_AD_UNIT_ID");
// 1. Recommended - Adaptive ad size that adjusts to the screen width
LevelPlayAdSize adSize = LevelPlayAdSize.createAdaptiveAdSize(this);

// 2. Adaptive ad size using fixed width ad size
// LevelPlayAdSize adSize = LevelPlayAdSize.createAdaptiveAdSize(this, 400);

// 3. Specific banner size - BANNER, LARGE, MEDIUM_RECTANGLE
// LevelPlayAdSize adSize = LevelPlayAdSize.BANNER;

if (adSize != null) {
// set the banner listener
// bannerAd?.setBannerListener(new YourBannerAdListener(this))

// add LevelPlayBannerAdView to your container

bannerAd.setAdSize(adSize);
bannerAd.loadAd();
} else {
// Handle banner ad creation failure
}

Interstitial

Supported ISInterstitialAdDelegate Callback

// Indicates that the interstitial ad was loaded successfully
@Override
public void onAdLoaded(LevelPlayAdInfo adInfo) {
// Handle interstitial ad loaded
}

// The interstitial ad failed to load. Use IronSource ErrorTypes (No Fill / Other)
@Override
public void onAdLoadFailed(LevelPlayAdError error) {
// Handle interstitial ad load failure
}

// Indicates the ad was displayed successfully to the user. This indicates an impression.
@Override
public void onAdDisplayed(LevelPlayAdInfo adInfo) {
// Handle interstitial ad opened
}

// User closed the interstitial ad
@Override
public void onAdClosed(LevelPlayAdInfo adInfo) {
// Handle interstitial ad closed
}

// The ad could not be displayed
@Override
public void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) {
// Handle interstitial ad failed to show
}

// Indicates the ad was clicked
@Override
public void onAdClicked(LevelPlayAdInfo adInfo) {
// Handle interstitial ad click
}

Initialization, Load, and Show Interstitial Ad

LevelPlayInterstitialAd interstitialAd = new LevelPlayInterstitialAd("YOUR_INTERSTITIAL_AD_UNIT_ID");
// interstitialAd.setListener(new YourInterstitialAdListener(this));
interstitialAd.loadAd();

if (interstitialAd.isAdReady()) {
interstitialAd.showAd(activity);
} else {
// Handle ad not ready scenario
}

Rewarded

Supported ISRewardedVideoAdDelegate Callback

// Indicates that rewarded video ad was loaded successfully 
@Override
public void onAdLoaded(LevelPlayAdInfo adInfo) {
// Handle rewarded video ad loaded
}

// The rewarded video ad failed to load. Use IronSource ErrorTypes (No Fill / Other)
@Override
public void onAdLoadFailed(LevelPlayAdError error) {
// Handle rewarded video ad load failure
}

// The rewarded video ad was displayed successfully to the user. This indicates an impression.
@Override
public void onAdOpened(AdInfo adInfo) {
// Handle rewarded video ad opened
}

// User closed the rewarded video ad
@Override
public void onAdClosed(AdInfo adInfo) {
// Handle rewarded video ad closed
}

// The ad could not be displayed
@Override
public void onAdShowFailed(IronSourceError ironSourceError, AdInfo adInfo) {
// Handle rewarded video ad failed to show
}

// User clicked the rewarded video ad
@Override
public void onAdClicked(Placement placement, AdInfo adInfo) {
// Handle rewarded video ad click
}

// User received a reward after watching the ad
@Override
public void onAdRewarded(Placement placement, AdInfo adInfo) {
// Handle user earned reward
}

Initialization, Load, and Show Rewarded Ad

LevelPlayRewardedAd rewardedAd = new LevelPlayRewardedAd("YOUR_REWARDED_VIDEO_AD_UNIT_ID");
// rewardedAd.setListener(new YourRewardedAdListener(this));
rewardedAd.loadAd();

if (rewardedAd.isAdReady()) {
rewardedAd.showAd(activity);
}

Set Privacy Settings

Change the privacy settings accordingly. By default, both are false. Please note that you have to set them before initializing the IronSource/LevelPlay SDK.

BlueStackPrivacySettings.setIsAgeRestrictedUser(true, context);
BlueStackPrivacySettings.setIsUserOptOut(true, context);

Error Handling

When handling ad operations, consider the following:

  • Check if the ad is ready before showing it.
  • Implement callbacks to handle errors during ad loading and displaying.
if (interstitialAd.isAdReady()) {
interstitialAd.showAd();
} else {
// Handle ad not ready scenario
}