Migrate to LevelPlay Init API
This guide explains how to transition to the LevelPlay initialization APIs to allow the use of multiple ad unit APIs.
- The min supported SDK is 8.4.0. You can download the latest SDK here.
Initialize the SDK
To initialize the ironSource SDK, follow these steps:
- Implement callbacks for initialization success and failure.
- Define the list of ad formats that require support from legacy ironSource API. This should include REWARDED.
- Call the LevelPlay init API using the appKey, ad formats, and user ID if relevant.
// Init the SDK when implementing the Multiple Ad Units Interstitial and Banner APIs, and Rewarded using legacy APIs
List<LevelPlay.AdFormat> legacyAdFormats = Arrays.asList(LevelPlay.AdFormat.REWARDED);
LevelPlayInitRequest initRequest = new LevelPlayInitRequest.Builder(appKey)
.withLegacyAdFormats(legacyAdFormats)
.withUserId("UserID")
.build();
LevelPlayInitListener initListener = new LevelPlayInitListener() {
@Override
public void onInitFailed(@NonNull LevelPlayInitError error) {
//Recommended to initialize again
}
@Override
public void onInitSuccess(LevelPlayConfiguration configuration) {
//Create ad objects and load ads
}
};
LevelPlay.init(context, initRequest, initListener);
// Init the SDK when implementing the Multiple Ad Units Interstitial and Banner APIs, and Rewarded using legacy APIs
val legacyAdFormats = listOf(LevelPlay.AdFormat.INTERSTITIAL,LevelPlay.AdFormat.REWARDED)
val initRequest = LevelPlayInitRequest.Builder("AppKey")
.withLegacyAdFormats(legacyAdFormats)
.withUserId("UserId")
.build()
LevelPlay.init(context, initRequest, object: LevelPlayInitListener {
override fun onInitFailed(error: LevelPlayInitError) {
//Recommended to initialize again
}
override fun onInitSuccess(configuration: LevelPlayConfiguration) {
//Create ad objects and load ads
}
})
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 ironSource SDK later (when internet connection is available, or when the failure reason is resolved).
Legacy | Ad Unit (new) | |
Class | IronSource | LevelPlay |
API | init | init |
setUserID | Should be set as part of LevelPlayInitRequest builder | |
Callbacks | onInitializationComplete | onInitSuccess |
– | onInitFailed |
The Integration Demo application demonstrates how to integrate the Ad Unit APIs in your app. Download Android Demo Application Done! You are now ready to implement the new ad units APIs.LevelPlay mediation demo app