Android SDK Integration

Before You Start

We support Android Operating Systems Version 4.1 (API Level 16) and above. Be sure to:

  • Use Android Studio 2.0 and above

  • Target Android API level 28

  • MinSdkVersion level 16 and above

Important! The ADAPTERS for ad networks are modularized as independent .aar files and should be downloaded as required by yourself. If you want to use AdTiming SDK to mediate networks, Be sure to follow our Add Mediation Networks and Mediation Integration Guides.

 

1. Overview

This Guideline introduces the integration of AdTiming's SDK in Android Apps.

AdTiming offers diversified and competent monetization services and supports a variety of Ad formats including Native Ad, Interstitial Ad, Banner Ad, and Rewarded Video Ad. The AdTiming platform mediates AdTiming, AdMob, Facebook, UnityAds, Vungle, Tapjoy, AppLovin, AdColony, Chartboost, MoPub, Pangle and IronSource.

New in Version 6.0 !

The newly designed AdTiming Mediation SDK (Version 6.0.0 and above), equipped with smart ad inventory mechanism and optimized SDK initialization pre-loading mechanism, provides the best mediation solution for app developers. For Rewarded Video, Interstitial and Interactive Ad, the SDK will cache ads automatically and maintain ad inventory regularly, such as pre-loading after initialization, loading after ad served and timing loading etc. You have no need to invoke load() method to cache ads by yourselves anymore with version 6.x.x. The new APIs are easier to use.
 

2. Ads ID

This section introduces how to fetch and use identity information when integrating the AdTiming SDK, including: APP_KEY, Placement ID, account and configurations of the mediation platform.

APP_KEY: APP_KEY is the sole identification of developer’s application on AdTiming platform. Developers need to create their Apps and obtain APP_KEY through the AdTiming Developer Platform.

  • Navigate to Apps -> Select 'Apps' -> Click on 'View All Apps'
    sdk_android_1_en.png
  • Click on 'Copy' 
    sdk_android_2_en.png

Placement ID: identifies the ads placement at Adtiming. Developers may create multiple ads placement on the AdTiming Developer Platform to meet their needs. The placement supports formats including BannerAd, InterstitialAd, NativeAd, VideoAd and InteractiveAd.

sdk_android_3_en.png

 

3. Add AdTiming SDK to your Project

AdTiming Supports both Gradle dependencies and manual download mechanisms to integrate our SDK.

Gradle dependencies

  • Add the following to your project-level build.gradle file inside repositories section.
...
allprojects { 
repositories {
...        
jcenter()
 maven {
           url '
       }
  }
}
  • Add the following to your application-level build.gradle file inside dependencies section.
dependencies {
    implementation  'com.adtiming:mediation-sdk:6.3.4@aar'
}

 

Manual Download

1.  Download Android SDK Version 6.3.4

2. Add the SDK to Your Project

Unzip and add the AdTimingSDK-x.x.x.aar to the libs folder in your Android Project.

Make sure you add the following to your Gradle build file under the dependencies section:

implementation (name:'AdTimingSDK-6.3.4', ext:'aar')

 

AdTiming Mediation Demo App

The Integration Demo application demonstrate how to integrate the AdTiming Mediation in your app.

Download Android Demo Application

 

4. Update AndroidManifest.xml

Configure your AndroidManifest.xml to add the following permissions into the manifest tag but outside the <application> tag.

<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

 

5. Proguard 

You must add the following to your Proguard configuration file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt) if you are using Porguard in your application. Failed to do so will lead to errors.

-dontwarn com.adtiming.mediationsdk.**.*
-dontwarn com.mopub.**.*
-dontwarn com.aiming.mdt.**.*
-dontskipnonpubliclibraryclasses
#AdTiming
-keep class com.adtiming.mediationsdk.mediation.**{*;}
-keep class com.mopub.**{*;}
-keep class com.aiming.mdt.**{*;}
-keep class com.adtiming.mediationsdk.mobileads.**{*;}

 #R
-keepclassmembers class **.R$* {
 public static <fields>;
}
-keepattributes *Annotation*
-keepattributes InnerClasses
-keepnames class * implements android.os.Parcelable {
   public static final ** CREATOR;
}

 

6. MultiDex

If your project has a multDex operation,Add the following to your build.gradle file.

android {
  buildTypes {
    release {
      multiDexKeepProguard file('multidex-config.pro')
      ...
    }
  }
}

 multidex-config.pro 

#adt
 -keep class com.adtiming.mediationsdk.mediation.**{*;}
 -keep class com.mopub.**{*;}
 -keep class com.aiming.mdt.**{*;}
 -keep class com.adtiming.mediationsdk.mobileads.**{*;}

 

7. Initialization

Before you can fetch ads from AdTiming Mediation Platform, you should first initialize the Adtiming SDK when your app started. To do so, we suggest to call AdTiming SDK's init() method within onCreate() of an Activity as belows:

import com.adtiming.mediationsdk.AdTimingAds;
public class DemoActivity extends Activity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      String appKey = "Your AppKey";
      AdTimingAds.init(this, appKey, new InitCallback() {

          // Invoked when the initialization is successful.
         @Override
          public void onSuccess() {
              //
          }

          // Invoked when the initialization is failed.
          @Override
          public void onError(AdTimingError message) {
              //
          }
      });
    }
}

Note:

  • APP KEY can only be obtained by creating apps on AdTiming.
  • Activity is the  must-have parameter.  Do not use temporary Activity object as parameter that will due to UnknowException. See Error Code for more information.
  • We suggest that the first call to method loadAd after the app starts should be in the onSuccess callback.
  • No need to invoke loadAd method for Rewarded Video & Interstitial Ads anymore, the SDK will fetch Ads automatic and maintain the ad inventory.
  • The error parameter in onError callback describes the cause of failure. Check the  Error Code for more information and guidance on errors. 

Best Practise: Init the SDK with AdUnits

The SDK can be  initialized in another way and we recommend this approach as it will only fetch the specific ad units you define in the adUnits parameter. The adUnits parameter is a string array. The following illustrates that the SDK is initiated with Rewarded_Video&Interstitial AdUnits and only these two types Ads will be fetched automatic. 

/**
*Ad Units should be in the type of AdTimingAds.AD_TYPE.AdUnitName, for example:
*/
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.INTERSTITIAL, AdTimingAds.AD_TYPE.REWARDED_VIDEO);

When using this init approach, you can initialize each ad unit separately at different touchpoints in your app flow in one session.

// Init Rewarded video
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.REWARDED_VIDEO); 
// Init Interstitial
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.INTERSTITIAL); 
// Init Interactive
AdTimingAds.init(this, appkey, mcallback, AdTimingAds.AD_TYPE.INTERACTIVE); 
// No need to invoke init for Banner and Native.

Note:

  • Important! The AD_UNITs of REWARDED_VIDEO and INTERSTITIAL must be initiated if you want to serve them in app, otherwise the SDK won't fetch and cache Ads inventory automaticly.
  • AD_Units such as Native and Banner Ad have no need to initiate separately. 

 Implement the Callback

The AdTiming SDK fires several events to inform you of your initialing SDK operation. To receive these events, register to the callback in the init() and implement the onSuccess() and onError() of it.

@Override
public void onSuccess() {
    // Add code here to process init success event.
}
@Override
public void onError(AdTimingError error) {
    // Add code here to process init failed event.
    // Parameter message tells the error information.
}

Note:

  • The error parameter in onError callback describes the cause of failure. Check the Error Code for more information and guidance on errors. 

 

Record Activity Lifecycle

Override the onPause()onResume() methods in each of your activities to call the corresponding AdTiming methods as follows:

protected void onResume() {
     super.onResume();
     AdTimingAds.onResume(this);
  } 
protected void onPause() {
     super.onPause();
     AdTimingAds.onPause(this);
  }

 

Set IAP Parameter(optional)

IAP, an acronym for in-App Purchase, can be understood as an in-app purchase. We need you to pass the current device user's IAP data to the SDK through the setIAP method in the APP so that we can provide more accurate advertising.

AdTimingAds.setIAP(float iapCount, String currency); 

The parameter currency is a String represents the currency code of the ISO, based on the International Organization for Standardization's national code, is published in the ISO 4217:2008 standard and is used to represent money and funds.

You could set IAP after SDK initial successfully, such as at the time the IAP data is changed.

… …
 AdTimingAds.setIAP(12.30f, "USD");
 … … 

 

Send attribution data to AdTiming(optional)

If your project also integrates the AppsFlyer SDK, we need you to pass the application attribution data to AdTiming so that we can help you accurately calculate each Media Source, Campaign level ROAS, and LTV data.

1. When you receive the onConversionDataSuccess callback you can use the sendAFConversionData method for passing the attribution data dictionary:

For apps using AppsFlyer SDK version 5 and above 

@Override
public void onConversionDataSuccess(Map<String, Object> conversionData) {
AdTimingAds.sendAFConversionData(conversionData); }

For apps using AppsFlyer SDK version 4 and below

@Override
public void onInstallConversionDataLoaded(Map<String, String> map) { {
AdTimingAds.sendAFConversionData(map); }

2. When you receive the onAppOpenAttribution callback you can use the sendAFDeepLinkData method for passing the attribution data dictionary:

@Override
public void onAppOpenAttribution(Map<String, String> conversionData) {
AdTimingAds.sendAFDeepLinkData(conversionData); }

 

8. GDPR

As a publisher, you should integrate a Consent Management Platform (CMP) and request for vendor and purpose consents as outlined in IAB Europe’s Mobile In-App CMP API v1.0: Transparency & Consent Framework.

You can find a reference implementation of a web-based CMP and the corresponding native wrappers here.

If you are embedding your own custom CMP, the collected end user consent information needs to be stored in PreferenceManager.getDefaultSharedPreferences using the following keys:

key value
IABConsent_CMPPresent boolean (Set to true if a CMP that follows the iAB specification is present in the application.)
IABConsent_SubjectToGDPR String “1” - (subject to GDPR),”0” - (not subject to GDPR),”-1” - Unknown (default before initialization)
IABConsent_ConsentString String (Base64-encoded consent string as defined in Consent string and vendor list format v1.1)
IABConsent_ParsedPurposeConsents String (String of “0”s and “1”s, where the character at position N indicates the consent status to purposeID N as defined in the Global Vendor List)
IABConsent_ParsedVendorConsents String (String of “0”s and “1”s, where the character at position N indicates the consent status to vendorID N as defined in the Global Vendor List)

 

9. COPPA

To protect children, AdTiming does not advertise for users under the age of 13, be sure to follow the following guidelines:
  1. In order to add new application at AdTiming publisher platform and successfully create ad placement, you have to agree to the COPPA compatibility option. Please make sure your app is not designated as a child-directed mobile application. And if it is, please do not check the compatibility option.

         sdk_android_4_en.png

  1. If your app is not a child-directed application but the users may include people under the age of 13, then you must have a mechanism in the app to determine whether the current user is over 13 years old. If the user is under the age of 13, please be aware that you should not initialize AdTiming SDK in the application for load&show ads. If your application initializes AdTiming SDK for load&show ads, we default that the current user for the app is 13 years old or above.
  2. If you add a child-directed application at AdTiming publisher platform by using deceptive means or without proactively having a mechanism to determine whether the current user is under the age of 13, or if you have an actual knowledge that the current user is under the age of 13 but you still initialize the AdTiming SDK for load&show ads, AdTiming will not be held legally responsible and AdTiming reserve the right to pursue your legal liability
 

Interested in Mediation? Integrate our Rewarded Video, Interstitial, Banner and Native Ads in your app and Follow our Add Mediation Networks and Mediation Integration Guides to mediation networks. With the AdTiming Mediation SDK, you need to download and add NOT ONLY the SDK of mediation networks  you choose to work with BUT ALSO the adapters for those networks.

Was this article helpful?
7 out of 9 found this helpful

Comments

0 comments

Article is closed for comments.