SDK Integration | Appodeal Intelligent Ad Mediation

SDK Integration

  1. Manual

App key

Link your Admob account

Appodeal yields optimal results in cooperation with Admob. To continue, you need to link your Admob account.

If you don't have Admob account, please sign up on Admob.com.

To link your Admob account to Appodeal, use the Chrome extension:

INSTALL EXTENSION


The extension source code is available at https://github.com/appodeal/admob-configurator.

The extension will make two changes in your Admob account. First, it will allow Appodeal to access your Admob reports over API, and second, it will create new ad units on Admob and submit them to Appodeal.

VIDEO TUTORIAL

Attention!

Starting from March 1, 2018, we will cease supporting PhoneGap framework. See more details here.

Download SDK

To install Appodeal PhoneGap Plugin to your project add following to your config.xml:

<gap:plugin name="com.appodeal.plugin" source="npm"/>

Minimum OS requirements: Android API level 9 (Android OS 2.3).

AndroidManifest.xml

All required changes to AndroidManifest.xml are already included in the plugin

PhoneGap Integration

Ad Types

Appodeal.INTERSTITIAL

Appodeal.SKIPPABLE_VIDEO

Appodeal.BANNER

Appodeal.REWARDED_VIDEO

Appodeal.NON_SKIPPABLE_VIDEO

Ad types can be combined using "|" operator. For example

Note that it is better to use NON_SKIPPABLE_VIDEO or REWARDED_VIDEO, but if you are sure you want to use SKIPPABLE_VIDEO you must confirm usage by calling Appodeal.confirm(Appodeal.SKIPPABLE_VIDEO) before SDK initialization

SDK Initialization

To initialize SDK, call the following code:

var appKey = "fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f";
Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.BANNER);

To initialize only interstitials use Appodeal.initialize(appKey, Appodeal.INTERSTITIAL)

To initialize only skippable videos use Appodeal.initialize(appKey, Appodeal.SKIPPABLE_VIDEO)

To initialize only rewarded video use Appodeal.initialize(appKey, Appodeal.REWARDED_VIDEO)

To initialize only non-skippable video use Appodeal.initialize(appKey, Appodeal.NON_SKIPPABLE_VIDEO)

To initialize interstitials and videos use Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.SKIPPABLE_VIDEO)

To initialize only banners use Appodeal.initialize(appKey, Appodeal.BANNER)

Display Ad

Appodeal.show(adTypes);

To display interstitial use Appodeal.show(Appodeal.INTERSTITIAL)

To display skippable video use Appodeal.show(Appodeal.SKIPPABLE_VIDEO)

To display rewarded video use Appodeal.show(Appodeal.REWARDED_VIDEO)

To display non-skippable video use Appodeal.show(Appodeal.NON_SKIPPABLE_VIDEO)

To display interstitial or video use Appodeal.show(Appodeal.INTERSTITIAL | Appodeal.SKIPPABLE_VIDEO)

To display banner at the bottom of the screen use Appodeal.show(Appodeal.BANNER_BOTTOM)

To display banner at the top of the screen use Appodeal.show(Appodeal.BANNER_TOP)

To display banner at the center of the screen use Appodeal.show(Appodeal.BANNER_CENTER)

Appodeal.show(adTypes, function(result){ // result is a boolean value, that is indicates whether show call was passed to appropriate SDK });

Hiding Banner

To hide banner you need to call the following code in activity:

Appodeal.hide(Appodeal.BANNER);

Samples

Display interstitial after it was loaded

Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
Appodeal.initialize(appKey, Appodeal.INTERSTITIAL);
Appodeal.cache(Appodeal.INTERSTITIAL);
Appodeal.enableInterstitialCallbacks(true);
document.addEventListener('onInterstitialLoaded', function(){
  Appodeal.show(Appodeal.INTERSTITIAL);
});

Display interstitial after app launch

Appodeal.initialize(appKey, Appodeal.INTERSTITIAL);
Appodeal.show(Appodeal.INTERSTITIAL);

Advanced Features

Checking if ad is loaded

Appodeal.isLoaded(adTypes, function(result){
  // result is a boolean value, that equals true if ad is loaded
});

To check if interstitial is loaded use Appodeal.isLoaded(Appodeal.INTERSTITIAL, function(result){})

To check if skippable video is loaded use Appodeal.isLoaded(Appodeal.SKIPPABLE_VIDEO, function(result){})

To check if rewarded video is loaded use Appodeal.isLoaded(Appodeal.REWARDED_VIDEO, function(result){})

To check if non-skippable video is loaded use Appodeal.isLoaded(Appodeal.NON_SKIPPABLE_VIDEO, function(result){})

To check if banner is loaded use Appodeal.isLoaded(Appodeal.BANNER, function(result){})

Checking if loaded ad is precache

Appodeal.isPrecache(adTypes, function(result){
  // result is a boolean value, that equals true if ad is precache
})

Currently supported only for interstitials , Use Appodeal.isPrecache(Appodeal.INTERSTITIAL, function(result){})

Setting Interstitial callbacks

Appodeal.enableInterstitialCallbacks(true);

document.addEventListener('onInterstitialLoaded', function(){});
document.addEventListener('onInterstitialFailedToLoad', function(){});
document.addEventListener('onInterstitialShown', function(){});
document.addEventListener('onInterstitialClicked', function(){});
document.addEventListener('onInterstitialClosed', function(){});

Setting skippable video callbacks

Appodeal.enableSkippableVideoCallbacks(true);

document.addEventListener('onSkippableVideoLoaded', function(){});
document.addEventListener('onSkippableVideoFailedToLoad', function(){});
document.addEventListener('onSkippableVideoShown', function(){});
document.addEventListener('onSkippableVideoFinished', function(){});
document.addEventListener('onSkippableVideoClosed', function(){});

Setting rewarded video callbacks

Appodeal.enableRewardedVideoCallbacks(true);

document.addEventListener('onRewardedVideoLoaded', function(){});
document.addEventListener('onRewardedVideoFailedToLoad', function(){});
document.addEventListener('onRewardedVideoShown', function(){});
document.addEventListener('onRewardedVideoFinished', function(data){
  console.log('Reward:' + data.amount + ' ' + data.name);  //data.amount  - amount of reward, data.name - reward name
});
document.addEventListener('onRewardedVideoClosed', function(){});

Setting non-skippable video callbacks

Appodeal.enableNonSkippableVideoCallbacks(true);

document.addEventListener('onNonSkippableVideoLoaded', function(){});
document.addEventListener('onNonSkippableVideoFailedToLoad', function(){});
document.addEventListener('onNonSkippableVideoShown', function(){});
document.addEventListener('onNonSkippableVideoFinished', function(){});
document.addEventListener('onNonSkippableVideoClosed', function(){});

Setting banner callbacks

Appodeal.enableBannerCallbacks(true);

document.addEventListener('onBannerClicked', function(){});
document.addEventListener('onBannerFailedToLoad', function(){});
document.addEventListener('onBannerLoaded', function(){});
document.addEventListener('onBannerShown', function(){});

Manual ad caching

Appodeal.cache(adTypes);

You should disable automatic caching before SDK initialization using setAutoCache(adTypes, false).

To cache interstitial use Appodeal.cache(Appodeal.INTERSTITIAL)

To cache skippable video use Appodeal.cache(Appodeal.SKIPPABLE_VIDEO)

To cache rewarded video use Appodeal.cache(Appodeal.REWARDED_VIDEO)

To cache interstitial and video use Appodeal.cache(Appodeal.INTERSTITIAL | Appodeal.SKIPPABLE_VIDEO)

To cache banner use Appodeal.cache(Appodeal.BANNER)

Enabling or disabling automatic caching

Appodeal.setAutoCache(adTypes, false);

Should be used before SDK initialization

To disable automatic caching for interstitials use Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false)

To disable automatic caching for skippable videos use Appodeal.setAutoCache(Appodeal.SKIPPABLE_VIDEO, false)

To disable automatic caching for rewarded videos use Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false)

To disable automatic caching for banners use Appodeal.setAutoCache(Appodeal.BANNER, false)

Triggering onLoaded callback on precache

Appodeal.setOnLoadedTriggerBoth(adTypes, true);

Currently supported only for interstitials

setOnLoadedTriggerBoth(Appodeal.INTERSTITIAL, false) - onInterstitialLoaded will trigger only when normal ad was loaded (default)..

setOnLoadedTriggerBoth(Appodeal.INTERSTITIAL, true) - onInterstitialLoaded will trigger twice, both when precache and normal ad were loaded..

Should be used before SDK initialization

Disabling networks

Appodeal.disableNetwork((String)network);

Available parameters: "amazon_ads", "applovin", "chartboost", "mopub", "unity_ads", "mailru", "facebook", "adcolony", "vungle", "yandex", "startapp", "avocarrot", "flurry", "pubnative", "cheetah", "inner-active", "revmob".

Should be used before SDK initialization

Disabling location permission check

To disable toast messages ACCESS_COARSE_LOCATION permission is missing, use the following method:

Appodeal.disableLocationPermissionCheck();

Should be used before SDK initialization.

Proguard Settings

If you are using Proguard

If you are using Proguard add the following to your Proguard config file:

# Appodeal
-keep class com.appodeal.** { *; }
-keep class org.nexage.** { *; }
-keepattributes EnclosingMethod, InnerClasses, Signature, JavascriptInterface

# Amazon
-keep class com.amazon.** { *; }
-dontwarn com.amazon.**

# Mopub
-keep public class com.mopub.**
-keepclassmembers class com.mopub.** { public *; }
-dontwarn com.mopub.**
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keepclassmembers class com.mopub.mobileads.CustomEventBannerAdapter {!private !public !protected *;}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}
-keep class * extends com.mopub.mobileads.CustomEventRewardedVideo {}
-dontwarn com.mopub.volley.toolbox.**
-keepclassmembers class ** { @com.mopub.common.util.ReflectionTarget *; } 

# Applovin
-keep class com.applovin.** { *; }
-dontwarn com.applovin.**

# Facebook
-keep class com.facebook.ads.** { *; }
-keeppackagenames com.facebook.*
-dontwarn com.facebook.ads.**

# Chartboost
-keep class com.chartboost.** { *; }
-dontwarn com.chartboost.**

# Unity Ads
-keepattributes SourceFile,LineNumberTable
-keep class com.unity3d.** { *; }
-dontwarn com.unity3d.**

# Yandex
-keep class com.yandex.metrica.** { *; }
-dontwarn com.yandex.metrica.**
-keep class com.yandex.mobile.ads.** { *; }
-dontwarn com.yandex.mobile.ads.**
-keepattributes *Annotation*

# StartApp
-keep class com.startapp.** { *;}
-dontwarn com.startapp.**
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, LineNumberTable, *Annotation*, EnclosingMethod

# Flurry
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
  public <init>(android.content.Context, android.util.AttributeSet, int);
}

# Avocarrot
-keep class com.avocarrot.** { *; }
-keepclassmembers class com.avocarrot.** { *; }
-dontwarn com.avocarrot.**
-keep public class * extends android.view.View {
  public <init>(android.content.Context);
  public <init>(android.content.Context, android.util.AttributeSet);
  public <init>(android.content.Context, android.util.AttributeSet, int);
  public void set*(...);
}

# Adcolony
-keep class com.jirbo.adcolony.** { *;}
-keep class com.adcolony.** { *;}
-keep class com.immersion.** { *;}
-dontnote com.immersion.**
-dontwarn android.webkit.**
-dontwarn com.jirbo.adcolony.**
-dontwarn com.adcolony.**

# Vungle
-keepattributes *Annotation*, Signature
-keep class com.vungle.** { *;}
-dontwarn com.vungle.**
-keep class com.moat.analytics.mobile.vng.** { *;}
-keep class dagger.**
-keep class de.greenrobot.event.**
-keep class javax.inject.**
-keep class rx.**

# MyTarget
-keep class com.my.target.** { *; }
-dontwarn com.my.target.**

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

# Tapjoy
-keep class com.tapjoy.** { *; }
-dontwarn com.tapjoy.**

# IronSource
-keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { public *; }
-keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }
-keep class com.ironsource.** { *; }
-dontwarn com.ironsource.**

# AdColonyV3
-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
-keep class com.adcolony.** { *; }
-dontwarn com.adcolony.**
-dontwarn android.app.Activity

#Appnext
-keep class com.appnext.** { *; }
-dontwarn com.appnext.**

# Inmobi
-keep class com.inmobi.** { *; }
-dontwarn com.inmobi.**
-dontwarn com.squareup.picasso.**
-keep class com.squareup.picasso.** {*;}
-dontwarn com.squareup.picasso.**
-dontwarn com.squareup.okhttp.**
-keep class com.moat.** {*;}
-dontwarn com.moat.**

# MMdeia
-keepclassmembers class com.millennialmedia** {public *;}
-keep class com.millennialmedia**
-dontwarn com.millennialmedia.**

# Ogury
-dontwarn io.presage.**
-dontnote io.presage.**
-dontwarn shared_presage.**
-dontwarn org.codehaus.**
-keepattributes Signature
-keep class shared_presage.** { *; }
-keep class io.presage.** { *; }
-keepclassmembers class io.presage.** { *; }
-keepattributes *Annotation*
-keepattributes JavascriptInterface
-keepclassmembers class * {
  @android.webkit.JavascriptInterface <methods>;
}
-dontnote okhttp3.**
-dontnote okio.**
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

-dontnote sun.misc.Unsafe
-dontnote android.net.http.*

-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**

-dontwarn org.apache.commons.collections.BeanMap
-dontwarn java.beans.**
-dontnote com.google.gson.**
-keepclassmembers class * implements java.io.Serializable {
  static final long serialVersionUID;
  private static final java.io.ObjectStreamField[] serialPersistentFields;
  private void writeObject(java.io.ObjectOutputStream);
  private void readObject(java.io.ObjectInputStream);
  java.lang.Object writeReplace();
  java.lang.Object readResolve();
}

# Google
-keep class com.google.android.gms.common.GooglePlayServicesUtil {*;}
-keep class com.google.android.gms.ads.identifier.** { *; }
-dontwarn com.google.android.gms.**

# Legacy
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.net.http.**

# Google Play Services library
-keep class * extends java.util.ListResourceBundle {
  protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
  public static final *** NULL;
}
-keepnames class * implements android.os.Parcelable
-keepclassmembers class * implements android.os.Parcelable {
  public static final *** CREATOR;
}
-keep @interface android.support.annotation.Keep
-keep @android.support.annotation.Keep class *
-keepclasseswithmembers class * {
  @android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
  @android.support.annotation.Keep <methods>;
}
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
  @com.google.android.gms.common.annotation.KeepName *;
}
-keep @interface com.google.android.gms.common.util.DynamiteApi
-keep public @com.google.android.gms.common.util.DynamiteApi class * {
  public <fields>;
  public <methods>;
}
-keep class com.google.android.gms.common.GooglePlayServicesNotAvailableException {*;}
-keep class com.google.android.gms.common.GooglePlayServicesRepairableException {*;}

# Google Play Services library 9.0.0 only
-dontwarn android.security.NetworkSecurityPolicy
-keep public @com.google.android.gms.common.util.DynamiteApi class * { *; }

# support-v4
-keep class android.support.v4.app.Fragment { *; }
-keep class android.support.v4.app.FragmentActivity { *; }
-keep class android.support.v4.app.FragmentManager { *; }
-keep class android.support.v4.app.FragmentTransaction { *; }
-keep class android.support.v4.content.ContextCompat { *; }
-keep class android.support.v4.content.LocalBroadcastManager { *; }
-keep class android.support.v4.util.LruCache { *; }
-keep class android.support.v4.view.PagerAdapter { *; }
-keep class android.support.v4.view.ViewPager { *; }
-keep class android.support.v4.content.ContextCompat { *; }

# support-v7-recyclerview
-keep class android.support.v7.widget.RecyclerView { *; }
-keep class android.support.v7.widget.LinearLayoutManager { *; }

Admob Adapter

Admob adapter for Appodeal is included with our jar.

To use it, do the following:

1. Go to your adUnit, click on “Mediation ad sources”

2. Add New ad network

3. Add new Custom Event:

Class Name - com.google.ads.mediation.appodeal.AppodealCustomEvent

Label - AppodealCustomEvent

Parameter - fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f

Admob1
Admob2

MoPub Adapter

MoPub adapter for Appodeal is included with our jar.

To use it, do the following:

1. On the MoPub Networks page click “Add Network”

2. Choose “Custom Native Network”

3. Enter the Custom Event Class information into the text boxes.

Custom Event Class - com.mopub.mobileads.AppodealCustomEventInterstitial

Custom Event Class Data - {"appKey":"fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f"}

Mopub1
Mopub2