Android SDK Integration

Prerequisites

  • API level 16
  • Android Jelly Bean, 4.1

For Android, we provide integration via a Maven repository which allows you to automatically download the proper DT offer Wall SDK according to the version number input into Gradle, or some other Maven-compatible system.

This greatly simplifies integration and is thus our recommended method. Downloading the SDK manually requires manual integration, which in turn requires significantly more steps and is more error-prone.

With Google officially moving their support to Android Studio, it is an obvious choice for DT to fully support Gradle, which is one of the most useful components of Android Studio.

Step 1: Integrating the SDK in your App

DT supports both Gradle dependencies or manual download to integrate our SDK:

Gradle
repositories {
     mavenCentral()
... } dependencies {
... implementation 'com.fyber:offerwall-sdk:9.2.4'
... }
Manual Download

For a quick download of the most recent version of the DT Offer Wall Android SDK click here:

Download v9.2.4

Add the DT Maven repository and DT Offer Wall SDK dependency to your build.gradle file.

All DT Offer Wall SDKs work in conjunction with Android's 64-bit architecture.

Integrating Google Play Services

We recommend you use the Google Play Services, as otherwise we aren't able to access your Google Advertising ID. This leads to limited ad inventory, as an increasing number of advertising campaigns require the identifier. This ID is also essential for tracking daily active users (DAU) on your app.

If you have not integrated Google Play Services yet, please follow the Google Play Services integration guide.

DT Offer Wall SDK only requires the com.google.android.gms:play-services-ads-identifier library. Your app may require additional APIs from Google Play Services.

You could simply include the entire library but doing so risks exceeding the DEX limit. It's optimal to only include the services you need.

To ensure we can access the Google Advertising ID, please include the following lines for Google Play Services:

Keep Google Ad ID

# Google Advertising Id

-keep class com.google.android.gms.ads.identifier.** { *; }

 

If your project uses ProGuard, be sure to follow Google's instructions to prevent it from stripping away required classes.

Step 2: Adding User Consent

GDPR

The General Data Protection Regulation requires you to scope your user's consent. For more information on GDPR, click here.

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

Once you have collected the user’s consent, you can pass them onto the SDK using the following API:

API

public static void setGdprConsent(final boolean isGdprConsentGiven, Context context)

Example

User.setGdprConsent(true, context);

context is valid Android's context.

isGdprConsentGiven is a boolean. It is true if you have the user’s consent. If you do not have the user's consent, it is false.

We recommend that the first time you gather the user’s consent, you pass it onto the SDK before starting the SDK. The SDK will then take the user’s consent into consideration when initializing. In the following sessions, you will only need to call the API if the user updates his or her consent.

More information on GDPR can be found under the GDPR Resource Page and FAQs.

Click here for details of the CCPA - Privacy String.

CCPA - Privacy String

The intention of the California Consumer Privacy Act of 2018 (CCPA) is to protect the personal information of California residents. CCPA applies to all companies doing business in California. If a California resident uses an app developer’s mobile app, CCPA applies to the developer and every company that processes the personal information of the app’s users.
CCPA came into effect on 1 January 2020.

For more information on DT and CCPA, refer to DT’s Resource Page.
For more information about CCPA, refer to the IAB CCPA Compliance Framework.

Setting the IAB US Privacy String

We recommend that the first time you gather a user opt-out (aka 'consent'), you pass it onto the SDK before initializing it. The SDK takes the user opt-out into consideration when initializing.

Once you have collected the user’s opt-out, you can pass it onto the SDK using the following API:

To set the IAB US privacy string, use the following API:

Java

String consentString = "1YNN";
User.setIabUsPrivacyString(consentString, context);

Clearing Privacy Opt-Out

To clear the user opt-out setting, use the following API:

Java

User.clearIabUsPrivacyString(context);

Step 3: Starting the SDK

You’ll need to start the DT Offer Wall SDK before being able to use any DT product.

Warning

  • Starting up the DT Offer Wall SDK when the main thread is performing a heavy operation (loading assets, etc) can result in an unresponsive state (for example, an ANR). This may lead to the app being down ranked in the app store. This is especially true for slower devices. For these reasons, It is advised to initialize the DT Offer Wall SDK after all the heavy operations are completed.
  • You must initialize the SDK on app start for accurate DAU calculations.

To do this, determine a point in your application’s code that runs when the application starts. We recommend the onResume method of your main activity.

START the SDK (RECOMMENDED Method)

import com.fyber.Fyber;

[...]

@Override
protected void onResume() {
	Fyber.with(appId, activity)
    			.withUserId(userId)
     			.withSecurityToken(securityToken)
     			.start();
}

The securityToken and appId are required, and can be found in the Settings of your app in the Dashboard. The userId should uniquely identify the user of your app.

Common Error

DT Offer Wall requires user ids to be unique within your app. You may not hardcode or share user ids. If necessary, the DT Offer Wall SDK can assign unique user ids for you (see below).

Automatically Generated user ids

The previous method is our preferred method of starting the SDK.

If you do not want to set a userId yourself and would rather the DT Offer Wall SDK create it for you, the DTOffer Wall SDK will do so when you omit the call to withUserId(...) in your code:

START the SDK (Alternative Method)

import com.fyber.Fyber;

[...]

@Override
protected void onResume() {
	Fyber.with(appId, activity)
     			.withSecurityToken(securityToken)
     			.start();
}

This generates the required unique userId on the first launch of the application and stores it for subsequent launches.

Subsequent usage of the DT Offer Wall SDK during your application's lifecycle will reuse the parameters passed to this call. If the user re-installs the app, a new userId will be generated.

Back to Top ⇧