Integrate Ad Quality SDK for Android

Facilitate the integration of the ironSource Android SDK, covering setup steps, modifying configuration files, and initializing SDKs for various ad formats and platforms.

Read time 8 minutes

Ad Quality helps you monitor and control the ad content your users see, so you can ensure it aligns with your app's goals and enhances user experience. Maximize your revenue potential while serving relevant ads that engage your audience.

Prerequisites

Follow our step-by-step guide and configure your application in the LevelPlay platform.

Step 1: Import the Ad Quality SDK to your app

Gradle

  1. Add the following to your app's build.gradle file inside repositories section:

repositories {
	mavenCentral()
}
  1. Then add the following to the dependencies section:

dependencies { 
    // ironSource Ad Quality SDK
    implementation 'com.unity3d.ads-mediation:adquality-sdk:7.25.2'
}

Step 2: Initialize the SDK

  1. Initialize the Ad Quality SDK using your ironSource app key, which can be found in the Unity LevelPlay Platform.
  2. Add the following code to your app's main thread, or on the same thread as your other ad network SDKs to initialize the Ad Quality SDK:

import com.ironsource.adqualitysdk.sdk.IronSourceAdQuality;
protected void onCreate(Bundle savedInstanceState) {
    // Initialize
    IronSourceAdQuality.getInstance().initialize(this, appKey);
}

Step 3 (optional): Advanced SDK Initialization

Customize your integration settings to get even more functionality with these special configurations:

  1. User ID: Use your own user IDs, instead of the default IDs from Ad Quality
  2. Test mode: Test your Ad Quality SDK integration (default is false)
  3. Log level: Choose a log level to debug code issues (default is INFO)

Use the code below to create your config object with a builder.


ISAdQualityConfig.Builder adQualityConfigBuilder = new ISAdQualityConfig.Builder();

User ID

The Ad Quality SDK provides two options for configuring your user IDs:

  1. Use your own user IDs, and add them before or during initialization:

adQualityConfigBuilder.setUserId(userId);
// The default user id is Ad Quality internal id.
// The user id cannot be null and must be between 2 and 100 characters, otherwise it will be blocked.
  1. Change the default user IDs after initializing the Ad Quality SDK, for cases for your IDs are set later.

IronSourceAdQuality.getInstance().changeUserId(userId);
// The default user id is Ad Quality internal id. 
// The user id cannot be null and must be between 2 and 100 characters, otherwise it will be blocked.

Test Mode


adQualityConfigBuilder.setTestMode(true); 
// The default is false - set to true only to test your Ad Quality integration

Log level


adQualityConfigBuilder.setLogLevel(ISAdQualityLogLevel.INFO);
// There are 5 different log levels:
// ERROR, WARNING, INFO, DEBUG, VERBOSE
// The default is INFO
ISAdQualityConfig adQualityConfig = adQualityConfigBuilder.build();
IronSourceAdQuality.getInstance().initialize(this, appKey, adQualityConfig);

Step 4 (optional): Configure SDK callback events

ISAdQualityInitListener:


ISAdQualityConfig.Builder builder = new ISAdQualityConfig.Builder().setAdQualityInitListener(new ISAdQualityInitListener() { 

    @Override 
    public void adQualitySdkInitSuccess() { 
        Log.d("AdQualityInitListener", "adQualitySdkInitSuccess"); 
    } 

    @Override 
    public void adQualitySdkInitFailed(ISAdQualityInitError error, String message) { 
        Log.d("AdQualityInitListener", "adQualitySdkInitFailed " + error + " message: " + message); 
    } 
}); 

ISAdQualityConfig adQualityConfig = builder.build();
IronSourceAdQuality.getInstance().initialize(this, appKey, adQualityConfig);

Step 5 (optional): Report impression-level ad revenue to Ad Quality SDK

Ad Quality SDK 7.2.0+ supports impression-level ad revenue report:

To report Impression-level ad revenue in the Ad Quality SDK, add the code snippet below to your SDK integration.


ISAdQualityCustomMediationRevenue.Builder builder = new ISAdQualityCustomMediationRevenue.Builder()                                                 
    .setMediationNetwork(ISAdQualityMediationNetwork.SELF_MEDIATED)                                                 
    .setAdType(ISAdQualityAdType.REWARDED_VIDEO)
    .setPlacement("placement")
    .setRevenue(0.12);
IronSourceAdQuality.getInstance().sendCustomMediationRevenue(builder.build());

If you're using AdMob mediation, follow these steps:

  1. Ask your AdMob account manager to enable AdMob impression-level LTV (iLTV)
  2. Verify that you use GMA SDK 8.12.0 or higher for Android or iOS and that the version supports iLTV
  3. Add the following code snippet to your Ad Quality SDK integration:

RewardedAd mRewardedAd;
 
@Override
public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
   mRewardedAd = rewardedAd;
   // Set paid event listener
   mRewardedAd.setOnPaidEventListener(new OnPaidEventListener() {
   @Override
   public void onPaidEvent(AdValue adValue) {
         ISAdQualityCustomMediationRevenue.Builder builder = new ISAdQualityCustomMediationRevenue.Builder()                                                                                                         
             .setMediationNetwork(ISAdQualityMediationNetwork.ADMOB)                                                                                                 
             .setAdType(ISAdQualityAdType.REWARDED_VIDEO)                                                      
             .setPlacement(mRewardedAd.getAdUnitId())                                                          
             .setRevenue(adValue.getValueMicros()/1000000.0);
         IronSourceAdQuality.getInstance().sendCustomMediationRevenue(builder.build());
       }
  });
}