Ad Quality SDK integration guides
The Ad Quality SDK enables you to run Ad Quality in your app. It automatically collects all the ad events and attributes needed from the ad network SDKs you currently use. This makes the integration simple and requires minimal coding.
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 {
maven {
url 'https://android-sdk.is.com/'
}
}
2. Then add the following to the dependencies section:
dependencies {
// ironSource Ad Quality SDK
implementation 'com.ironsource:adqualitysdk:6.9.7'
}
Step 2: Initialize the SDK
- Initialize the Ad Quality SDK using your ironSource app key, which can be found in the platform under Settings.
- 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: Advanced SDK Initialization
Customize your integration settings to get even more functionality with these special configurations:
- User ID – Use your own user IDs, instead of the default IDs from Ad Quality
- Test mode – Test your Ad Quality SDK integration (default is false)
- 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
adQualityConfigBuilder.setUserId(userId);
// The default user id is Ad Quality internal id.
// The only allowed characters for user id are: letters, numbers, @, -, :, =, _ and /.
// 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);
Configure your user IDs
Using your existing user IDs will streamline the way you manage users across platforms.
If you initialize the Ad Quality SDK without your user IDs, Ad Quality will set default user IDs.
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);
2.Change the default user IDs after initializing the Ad Quality SDK:
IronSourceAdQuality.getInstance().changeUserId(userId);
Step 4: 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): Managing GDPR consent
The Ad Quality SDK supports publisher communication of a user’s consent choice in accordance with GDPR regulations.
Use the following function to update a user’s consent status using the Ad Quality API:
If the user-provided consent, set the flag to true:
IronSourceAdQuality.getInstance().setUserConsent(true);