Documentation

​
​

Development

User Acquisition

Monetization

Industry

LevelPlay SDK - Android

Unity SDK

Android SDK

iOS SDK

Adobe AIR SDK

Flutter SDK

React Native SDK

LevelPlay SDK - Android

Unity LevelPlay
​
​
Android SDK
  • Get started
  • Regulations and settings
  • Ad formats
    • Rewarded ads
      • Migrate to rewarded ad unit API
    • Interstitial
    • Banner and MREC
    • Native ads
  • Mediated networks
  • Test your integration
  1. Grow your game
  2. Unity LevelPlay
  3. LevelPlay SDK
  4. LevelPlay SDK for Android developers

Migrate to rewarded ad unit API for Android

Migrate to the LevelPlay Rewarded Ad Unit API by initializing the SDK, creating a rewarded ad object with an ad unit ID, and implementing a listener for ad events.
Read time 6 minutes
Last updated 6 months ago

This guide explains how to integrate the LevelPlay APIs as of SDK version 9.0.0 using an ad unit ID as a waterfall identifier to load and display rewarded ads.
Important
Use the APIs introduced in this article instead of the integration methods currently in use (ironSource init, ironSource load rewarded, rewarded listeners). You can find the API replacements in the API Comparison section.
The advanced settings and regulations settings have not been changed, and they are supported before or after initializing the LevelPlay SDK.

Locate the ad unit ID in the LevelPlay platform

To load and display rewarded ads, you need to use the ad unit ID available in LevelPlay mediation platform:
  1. In your LevelPlay account, navigate to Setup > Ad Units.
  2. Copy the rewarded ad unit ID and integrate it into your code.

Initializing the LevelPlay SDK

To initialize the LevelPlay SDK, follow these steps:
  1. Implement callbacks for initialization success and failure.
  2. Call the LevelPlay init API using the appKey and user ID if relevant.
LevelPlayInitRequest initRequest = new LevelPlayInitRequest.Builder(appKey) .withUserId("UserID") .build();LevelPlayInitListener initListener = new LevelPlayInitListener() { @Override public void onInitFailed(@NonNull LevelPlayInitError error) {} @Override public void onInitSuccess(LevelPlayConfiguration configuration) {}};LevelPlay.init(context, initRequest, initListener);
val initRequest = LevelPlayInitRequest.Builder("AppKey") .withUserId("UserId") .build()LevelPlay.init(context, initRequest, object : LevelPlayInitListener { override fun onInitSuccess(configuration: LevelPlayConfiguration) {} override fun onInitFailed(error: LevelPlayInitError) {}})

LevelPlay Init Listeners

onInitSuccess: triggered when the initialization is completed successfully. After you receive this indication, you can create and load the ad.
onInitFailed: the configuration was not retrieved successfully and ads cannot be loaded. It is recommended to try and initialize the LevelPlay SDK later (when internet connection is available, or when the failure reason is resolved).

Init

Legacy

Ad Unit (new)

APIIronSource.initLevelPlay.init
CallbacksonInitializationCompleteonInitSuccess
–onInitFailed

Create Rewarded Ad Object

The creation of the rewarded ad object must be performed after receiving the onInitSuccess callback.
The object is a reusable instance that can handle multiple loads and shows throughout the session. When created, it should be used to load and show ads for the same ad unit.
For more advanced implementations, you may create multiple rewarded ad objects if necessary.
// Create rewarded AdmRewardedAd = new LevelPlayRewardedAd("adUnitId");
// Create rewarded AdmRewardedAd = LevelPlayRewardedAd("adUnitId")

Register to Rewarded Events

Set the rewarded listener for the rewarded ad unit created, to get informed of ad delivery.
  • It is recommended to set the listener before loading the rewarded ad.
  • Each rewarded ad should have its own listener implementation.
  • Callbacks run on the main thread.
// Create rewarded AdmRewardedAd = new LevelPlayRewardedAd("adUnitId");// Set listenermRewardedAd.setListener(this);// LevelPlayRewardedAdListener methods@Overridepublic void onAdLoaded(@NonNull LevelPlayAdInfo adInfo) {}@Overridepublic void onAdLoadFailed(@NonNull LevelPlayAdError error) {}@Overridepublic void onAdDisplayed(@NonNull LevelPlayAdInfo adInfo) {}@Overridepublic void onAdDisplayFailed(@NonNull LevelPlayAdError error, @NonNull LevelPlayAdInfo adInfo) {}@Overridepublic void onAdClosed(@NonNull LevelPlayAdInfo adInfo) {}@Overridepublic void onAdClicked(@NonNull LevelPlayAdInfo adInfo) {}@Overridepublic void onAdInfoChanged(@NonNull LevelPlayAdInfo adInfo) {}@Overridepublic void onAdRewarded(@NonNull LevelPlayReward reward, @NonNull LevelPlayAdInfo adInfo) {}
// Create rewarded AdmRewardedAd = LevelPlayRewardedAd("adUnitId") // Set listenermRewardedAd.setListener(this)// LevelPlayRewardedAdListener methodsoverride fun onAdLoaded(adInfo: LevelPlayAdInfo) {}override fun onAdLoadFailed(error: LevelPlayAdError) {}override fun onAdInfoChanged(adInfo: LevelPlayAdInfo) {}override fun onAdDisplayed(adInfo: LevelPlayAdInfo) {}override fun onAdDisplayFailed(error: LevelPlayAdError, adInfo: LevelPlayAdInfo) {}override fun onAdClicked(adInfo: LevelPlayAdInfo) {}override fun onAdClosed(adInfo: LevelPlayAdInfo) {}override fun onAdRewarded(reward: LevelPlayReward, adInfo: LevelPlayAdInfo) {}

LevelPlay Rewarded Ad Callbacks

onAdLoaded: Provided when the ad is successfully loaded.
onAdLoadFailed: Provided when the ad fails to load. Ad Unit information is included.
onAdDisplayed: Provided when the ad is displayed. This is equivalent to an impression.
onAdDisplayFailed: Provided when the ad fails to be displayed.
onAdRewarded: Provided when the ad is rewarded. Ad Unit info and the reward info are included.
onAdClicked (optional): Provided when the user clicks on the ad.
onAdClosed: Provided when the ad is closed.
onAdInfoChanged (optional): Provided when the ad info is updated. Available when another ad has loaded, and includes a higher CPM/Rate.

Component

Legacy

Ad Unit (new)

ListenerIronSourceRewardedVideoEventsLevelPlayRewardedAd
CallbacksonAdReadyonAdLoaded
onAdLoadFailedonAdLoadFailed
onAdOpenedonAdDisplayed
onAdClosedonAdClosed
onAdShowFailedonAdDisplayFailed
onAdRewardedonAdRewarded
onAdClickedonAdClicked
onAdShowSucceededn/a (deprecated)
n/aonAdInfoChanged

Load Rewarded Ad

Once you receive the onInitSuccess callback, you are ready to load a rewarded ad. This should be done using the method:
// Load or reload the admRewardedAd.loadAd();
// Load or reload the admRewardedAd.loadAd()

Show Rewarded Ad

You can show a rewarded ad after you receive onAdLoaded callback, using the showAd APIs. If you are using placements, share their name as part of the API, as shown below.
// Show ad without placement mRewardedAd.showAd(this);// Show ad with placement mRewardedAd.showAd(this, placementName);
// Show ad without placement mRewardedAd.showAd(this)// Show ad with placement mRewardedAd.showAd(this, placementName)

Check Ad is Ready

To avoid show failures, and to make sure the ad could be displayed correctly, we recommend using the following API, before calling the showAd API.
isAdReady – returns true if ad was loaded successfully and ad unit is not capped, or false otherwise.
isPlacementCapped – returns true when a valid placement is capped. If the placement is not valid, or not capped, this API will return false.
// Check that ad is ready and that the placement is not capped if(mRewardedAd.isAdReady() && !LevelPlayRewardedAd.isPlacementCapped(placementName)) { mRewardedAd.showAd(this, placementName);}
// Check that ad is ready and that the placement is not capped if (mRewardedAd.isAdReady() && !LevelPlayRewardedAd.isPlacementCapped(placementName)) { mRewardedAd.showAd(this, placementName)}
When the ad displays successfully to the player, you can load another ad, repeating the Load Rewarded Ad step. There is no need to create a new ad entity, when loading a single ad at a time.

Reward the User

The LevelPlay SDK will fire the onAdRewarded each time the user successfully completes a video.
The onAdRewarded and onAdClosed are asynchronous. Make sure to set up your listener to grant rewards even in cases where onAdRewarded is fired after the onAdClosed.
@Overridepublic void onAdRewarded(@NonNull LevelPlayReward reward, @NonNull LevelPlayAdInfo adInfo) { // Implement logic to grant the reward to the user String name = reward.getName(); int amount = reward.getAmount();}
override fun onAdRewarded(reward: LevelPlayReward, adInfo: LevelPlayAdInfo) { // Implement logic to grant the reward to the user val name: String = reward.name val amount: Int = reward.amount}

Multiple Ad Unit Rewarded APIs

Component

Legacy

Ad Unit (new)

ClassIronSourceLevelPlayRewardedAd
APIloadRewardedVideoloadAd
showRewardedVideoshowAd
isRewardedVideoPlacementCappedisPlacementCapped
isRewardedVideoAvailableisAdReady
placement.getRewardNamereward.name
placement.getRewardAmountreward.amount

Full Implementation Example of Rewarded Ad

public class RewardedAdActivity extends Activity implements LevelPlayRewardedAdListener { private LevelPlayRewardedAd mRewardedAd; void createRewardedAd() { mRewardedAd = new LevelPlayRewardedAd("adUnitId"); mRewardedAd.setListener(this); } void loadRewardedAd() { // Load or reload the ad mRewardedAd.loadAd(); } void showRewardedAd() { if (mRewardedAd.isAdReady()) { mRewardedAd.showAd(this); } } void showRewardedAd(@NonNull String placementName) { // Check that ad is ready and that the placement is not capped if (mRewardedAd.isAdReady() && !LevelPlayRewardedAd.isPlacementCapped(placementName)) { mRewardedAd.showAd(this, placementName); } } // LevelPlayRewardedAdListener methods @Override public void onAdLoaded(@NonNull LevelPlayAdInfo adInfo) {} @Override public void onAdLoadFailed(@NonNull LevelPlayAdError error) {} @Override public void onAdDisplayed(@NonNull LevelPlayAdInfo adInfo) {} @Override public void onAdClosed(@NonNull LevelPlayAdInfo adInfo) {} @Override public void onAdClicked(@NonNull LevelPlayAdInfo adInfo) {} @Override public void onAdDisplayFailed(@NonNull LevelPlayAdError error, @NonNull LevelPlayAdInfo adInfo) {} @Override public void onAdInfoChanged(@NonNull LevelPlayAdInfo adInfo) {} @Override public void onAdRewarded(@NonNull LevelPlayReward reward, @NonNull LevelPlayAdInfo adInfo) {}}
class RewardedAdActivity : Activity(), LevelPlayRewardedAdListener {private lateinit var mRewardedAd: LevelPlayRewardedAdfun createRewardedAd() { mRewardedAd = LevelPlayRewardedAd("adUnitId") mRewardedAd.setListener(this)}fun loadRewardedAd() { mRewardedAd.loadAd()}fun showRewardedAd() { if (mRewardedAd.isAdReady()) { mRewardedAd.showAd(this) }}fun showRewardedAd(placementName: String) { // Check that ad is ready and that the placement is not capped if (mRewardedAd.isAdReady() && !LevelPlayRewardedAd.isPlacementCapped(placementName)) { mRewardedAd.showAd(this, placementName) }}// LevelPlayRewardedAdListener methodsoverride fun onAdLoaded(adInfo: LevelPlayAdInfo) {}override fun onAdLoadFailed(error: LevelPlayAdError) {}override fun onAdInfoChanged(adInfo: LevelPlayAdInfo) {}override fun onAdDisplayed(adInfo: LevelPlayAdInfo) {}override fun onAdDisplayFailed(error: LevelPlayAdError, adInfo: LevelPlayAdInfo) {}override fun onAdClicked(adInfo: LevelPlayAdInfo) {}override fun onAdClosed(adInfo: LevelPlayAdInfo) {}override fun onAdRewarded(reward: LevelPlayReward, adInfo: LevelPlayAdInfo) {}}

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.

  • On this page
    • Locate the ad unit ID in the LevelPlay platform

    • Initializing the LevelPlay SDK

      • LevelPlay Init Listeners

    • Create Rewarded Ad Object

    • Register to Rewarded Events

      • LevelPlay Rewarded Ad Callbacks

    • Load Rewarded Ad

    • Show Rewarded Ad

      • Check Ad is Ready

    • Reward the User

    • Multiple Ad Unit Rewarded APIs

    • Full Implementation Example of Rewarded Ad


Report a problem with this page