Integrating the Android SDK
This guide describes how to integrate the DT Exchange SDK into your Android project, which uses Maven Central for dependency management.
Prerequisites
Android 4.4+ (API Level 19)
Step 1: Integrating the SDK in your App
You can integrate the DT Exchange SDK using either Maven Central dependencies or a manual download. Select one of the following options:
Configuring Maven Central
To add DT Maven repository and plugins to your Gradle build script:
Add the following to your app product-level
build.gradleinside the repositories section.At the root level
build.gradlefile, there are usually two repository sections - one forbuildscriptand one forallprojects. Add the entry inallprojects:
allprojects {
repositories {
// add this
mavenCentral()
}
// ...
}Add the following to the project app-level
gradlefile inside thedependenciessection.
Manually Downloading the SDK
To download the DT Exchange Android SDK, click here:
Log in to the DT Console.
Copy the following files from the
Fyber Marketplace SDKfolder to yourproject libsfolder.For version 8.4.3:
fyber-marketplace-8.4.3.aarFor version 8.1.0 and above (for Open Measurement support):
omsdk-android-1.5.4-release.aar
Add the following repositories and dependencies to the project
build.gradlefile:
Step 2: Integrating Google Play Services
DT recommends using Google Play Services to access your Google Advertising ID. This ID tracks your app's daily active users (DAU), and many ad campaigns require it. Without the ID, ad inventory is limited.
In the app-level
build.gradlefile, add the following dependencies:
For apps targeting API Level 31 (Android 12) or higher, declare the Google Play Services permission in the
AndroidManifest.xmlfile. This step is required unless the app uses a recent Google Mobile Ads SDK version.
For further information about Google Advertising ID Restrictions, read the following:
Google Advertising ID Restrictions
Permission Required for Advertising ID
Google Advertising ID (GAID) is a unique string identifier that anonymously identifies a device for advertising purposes. Google Play Services provides this Advertising ID and enables users to opt out of personalized ads in apps or reset their identifier. When a user resets their identifier, it can connect to a previous identifier.
In 2021, Google announced a behavior change for apps targeting Android 13 (API Level 33) and higher, a AD_ID permission is required. For more information, see Advertising ID.
To receive the Advertising ID, developers must add a new permission to the manifest file unless the app uses a recent version of the Google Mobile Ads SDK:
XML
Recent versions of the Google Mobile Ads SDK (play-services-ads v20.4.0 and higher, or play-services-ads-identifier v17.1.0 and higher) include this permission. If the app uses these SDKs, the AD_ID permission from the SDK's library manifest merges with your app's main manifest by default, making the Advertising ID available.
For more information about Google Play Services, see Set Up Google Play Services.
Step 3: Adding Permissions - Android Manifest File
Add the following mandatory permission to your
AndroidManifest.xmlfile:
To enhance targeting capabilities, add these permissions:
The ACCESS_NETWORK_STATE permission differentiates WiFi from a cellular network.
Step 4: Initializing the SDK
SDK initialization is mandatory because the DT SDK relies on the Console configuration for functionality. Without it, the SDK won't operate, and no ads will display. DT recommends performing this step during the app's initialization. Follow these steps to initialize the SDK.
Google Play Families Ads API
To participate in the Google Play Families Ads program, run the following code to indicate if the user is a child:
Call this API once per app session before initializing the SDK. If the app doesn't contain the API, the user is not considered a child user by default.
After configuring your AndroidManifest file and preparing to request ads, initialize InneractiveAdManager.initialize(context, <"appID">), and pass on your Activity or application context with the following code:
Call InneractiveAdManager.destroy() when you no longer need the library to display more ads, as this release any resources used by the SDK.
If you intend to destroy the library from within your activity's onDestroy method, ensure that the activity has finished.
To adjust or debug the logging library level, see DT Logging on Android.
Locating the App ID
To locate the App ID on the DT Console:
From the DT Console, go to Monetization→App Management. The Apps dashboard window appears.
Navigate to the required app. The App ID appears below the app's name.
Initialization Callback
You can use the following initialization callback to InneractiveAdManager to monitor the SDK's initialization status:
Valid values:
SUCCESSFULLY: SDK initialized successfully.FAILED_NO_KITS_DETECTED: Only thecoreDT Exchange library detected. Check dependencies and add thevideo-kitandmraid-kit.FAILED: SDK failed to communicate with servers. Retry initialization.INVALID_APP_ID: Incorrect app ID. Verify configuration or contact support.
DT recommends not using the SDK or performing ad requests when the FyberInitStatus is FAILED. The SDK attempts to re-initialize itself internally when an ad request is executed, but the callback is not invoked in such cases.
Passing a User ID to the SDK
To set a User ID for the SDK session, run the following code:
The initial method of the SDK must be called in advance; there is no need to wait for the onFyberMarketplaceInitialized callback.
The basic Android SDK integration is complete. You can now integrate other ad types as required. For more information, see Android Ad Formats.
Review the instructions below for user consent related issues.
Step 5: Adding User Consent
User consent mechanisms comply with various data protection laws. The following regulations mandate that users' data be handled with explicit consent:
GDPR
The General Data Protection Regulation of the European Union (GDPR) requires you to implement a user consent mechanism. A user is within the GDPR scope for your app when one or all of the following apply:
The user is currently located in the EU.
The user has registered with the app as an EU resident.
The app is specifically targeted to EU users.
To comply with EU regulations and ensure seamless ad monetization, DT recommends consulting a legal advisor to determine the best approach for your business and using a Consent Management Platform (CMP).
If you haven’t updated to SDK 8.3.0 or later, you need to manually configure consent values with your CMP. The SDK automatically retrieves these values from 8.3.0 and later, eliminating the need for manual setup. For a complete list of CMPs, see the Interactive Advertising Bureau - CMP List.
To incorporate GDPR consent values manually, set the setGdprConsent API in Boolean format, for example:
Valid values:
True: The user grants consent.False: The user does not grant consent.
Setting Consent String
The user's consent status must be passed to the SDK before the SDK is initialized. When you set a GDPR consent value for a user, DT assumes that the user is subject to GDPR rules, even if the user is outside Europe. If a user updates their consent later, you only need to call the API again with the new value.
To set the GDPR consent string, use the following API:
To clear the consent flag and consent data, use the following API:
If you don't obtain the user's consent before sending the SDK, only contextual ads appear.
CCPA
The California Consumer Privacy Act of 2018 (CCPA) protects the personal information of California residents and applies to all companies operating in California. If a California resident uses a mobile app developer's app, CCPA applies to the developer and every company that processes the personal information of the app's users.
For more information on CCPA and DT's practices, see US Privacy Compliance and IAB CCPA Compliance Framework.
CCPA API
To set the CCPA consent string, use the following API:
DT supports the following values for the US Privacy String:
1---: CCPA does not apply, for example, the user is not a California resident.1YNN: User does NOT opt out, ad experience continues.1YYN: User opts out of targeted advertising.
For more information, see IAB US Privacy String.
To clear the privacy setting flag and opt-out data, use the following API:
LGPD
The Brazilian General Data Protection Law, the Lei Geral de Proteção de Dados Pessoais (LGPD), mandates processing personal data for legitimate, specific, explicit, and communicated purposes.
To set the LGPD consent values, use the following API:
Valid values:
IALGPDConsentTypeGiven:True.IALGPDConsentTypeDenied:False.
If the consent value is not set, the default is False.
COPPA
The Children's Online Privacy Protection Act of 1998 (COPPA) is a federal law that imposes specific requirements on websites and online service operators to protect the privacy of children under 13.
COPPA API for Flagging Specific Users
Android SDK 8.2.3 and later supports the COPPA API, which allows publishers to flag specific end users as children as required under COPPA.
Execute the COPPA API after successfully initializing the DT SDK and after every successful SDK initialization
To confirm that the target audience of the application applies to COPPA, use the following API:
It is the publisher’s responsibility to decide whether to use the COPPA API or to treat all users as children. If you want flag all users as children, see COPPA.
Step 6: Configure Parameters
To add gender and age parameters, use the following API:
Step 7: app-ads.txt
The app-ads.txt standard helps prevent the unauthorized selling of in-app inventory and app domain spoofing.
For more information about how to list your Developer Website URL in the Google Play Store, see Adding a Developer Website.
Step 8: (Optional ) Using the DT Exchange SDK in Secure Only Mode
The InneractiveAdManager API enables you to control how the SDK should perform any network connections.
By invoking this setter with a value of true, all outgoing network connections from the DT Exchange SDK will use SSL/HTTPS. The default behavior is not to use secure connections.
Requesting secure-only content may decrease the demand that the SDK can render.
The Android application-level secure API (network-security-config cleartextTrafficPermitted) takes precedence over this value. If you set cleartextTrafficPermitted to false and invoke the useSecureConnections setter with a value of false, the SDK behaves as if you requested secure connections only.
Last updated
