SDK Integration | Appodeal

SDK Integration

  1. Manual

App key

Download SDK

To install Appodeal Cordova Plugin to your project simply run following command:

cordova plugin add https://github.com/appodeal/appodeal-cordova-plugin.git

If you're using MultiDex in your application, use this plugin:

cordova plugin add https://github.com/appodeal/appodeal-cordova-nodex-plugin.git

If you're not using MultiDex in your application and encountering 65K methods limit, use this plugin:

cordova plugin add https://github.com/appodeal/appodeal-cordova-maxdex-plugin.git

Google Play Services already included to plugin dependencies.

If you have issues while installing plugin, follow the Command-line Interface Guide.

Minimum OS requirements: iOS 8.1, Android API level 14 (Android OS 4.0).

Android Appodeal SDK version 2.1.4

iOS Appodeal SDK version 2.1.4

AndroidManifest.xml

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

Note: you can remove optional permissions in plugin.xml from plugins/com.appodeal.plugin if you don't want to use it. Following permissions are optional:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!--optional -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!--optional -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!--optional-->

Cordova Integration

Ad Types

Appodeal.INTERSTITIAL

Appodeal.BANNER

Appodeal.REWARDED_VIDEO

Appodeal.NON_SKIPPABLE_VIDEO

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

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 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 non-skippable videos use Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.NON_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 rewarded video use Appodeal.show(Appodeal.REWARDED_VIDEO)

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

To display interstitial or non-skippable video use Appodeal.show(Appodeal.INTERSTITIAL | Appodeal.NON_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)

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);

Advanced Features

Enabling test mode

Appodeal.setTesting(true);

In test mode test ads will be shown and debug data will be written to log

Enabling logging

Appodeal.setLogLevel(Appodeal.LogLevel.debug);

Available parameters: Appodeal.LogLevel.none, Appodeal.LogLevel.debug, Appodeal.LogLevel.verbose

Enables debug logging.

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 and banners

To check if loaded interstitial is precache: use Appodeal.isPrecache(Appodeal.INTERSTITIAL);

To check if loaded banner is precache: use Appodeal.isPrecache(Appodeal.BANNER);

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 rewarded video use Appodeal.cache(Appodeal.REWARDED_VIDEO)

To cache interstitial and non-skippable video use Appodeal.cache(Appodeal.INTERSTITIAL | Appodeal.NON_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 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.setTriggerOnLoadedOnPrecache(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 data collection for kids apps

Appodeal.setChildDirectedTreatment(true);

Disabling networks

Appodeal.disableNetwork(network);

Available parameters: "adcolony", "admob", "amazon_ads", "applovin", "appnext", "avocarrot", "chartboost", "facebook", "flurry", "inmobi", "inner-active", "ironsource", "mailru", "mmedia", "mopub", "ogury", "openx", "pubnative", "smaato", "startapp", "tapjoy", "unity_ads", "vungle", "yandex"

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.

Disabling write external storage permission check

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

Appodeal.disableWriteExternalStoragePermissionCheck();

Disables all ad networks that need this permission may lead to low video fillrates

Should be used before SDK initialization

Tracking in-app purchase

Appodeal.trackInAppPurchase(this, 5, "USD");

Testing third-party networks adapters integration

To show test screen for testing adapters integration call:

Appodeal.showTestScreen();

Muting videos if call volume is muted

Appodeal.muteVideosIfCallsMuted(true);

Setting User Data

Set the age of the user

Appodeal.setAge(25);

Specify gender of the user

Appodeal.setGender(UserSettings.Gender.FEMALE);

Possible values: Appodeal.Gender.FEMALE, Appodeal.Gender.MALE, Appodeal.Gender.OTHER.

Segments and Placements

Segments are divisions of your user base, which share commonalities such as age, sex, location, interests, income bracket, etc. There are several ways to segment users into groups including the use of demographics, in-app behavior or engagement analysis, interests and personal profile data, and location.

Once user segments have been created, they can then be analyzed and used to configure ads.

To create new segment go here

1) Enter its name

2) Select match rule:

  • ALL - user will only match to segment if all of the rules will apply to them
  • ANY - user will match to segment if any of the rules will apply to them

3) Select platform

4) Select rules that apply to the user, you can select as many rules as you want or none at all:

  • App - match users in one or multiple of your apps
  • SDK version - match users that only use specified sdk version or range of versions
  • Device type - match users that using tablet and/or phone
  • App version - match users that only use specified app version or range of versions
  • Country - match users only from specified countries
  • OS version - match users that are using devices with specified Android
  • Has app installed - only match users that have specified apps installed
  • Session count - match users that had specified number of sessions in your app
  • Average session length - match users with specified that spent specified average session length in your app
  • Device model - match user on specified devices
  • Connection type - match users using specified connection type
  • Gender, Age, Occupation, Relation - matches users with specified Gender, Age, Occupation, Relation
  • Last session time - matches users that last used your app at the specified time
  • Bought inapps - matches users that made in app purchases(tracked using Appodeal.trackInAppPurchase method)
  • Inapp sum, Inapp sum all apps - matches users the spent specified amount in your the app or all apps (only counts inapps tracked using Appodeal.trackInAppPurchase method)
  • Hour, Day - matches users using the app at the specified time
  • NSUInteger, CGFloat, NSString, Bool - matches users using custom parameters. You can set custom parameters in SDK using APDSdk .sharedSdk().setCustomRule(customRule) method, i.e. APDSdk .sharedSdk().setCustomRule(["levels_played" : 3]). To match users that played more than 3 level select Int and enter name "levels_played", select operator > and value 3

5) Segment settings. You can apply following settings for each segment. They will apply to all users matched to that segment.

  • Disable networks. Allows you to disable any network for ant ad type it supports
  • Min pricefloor. Allows you to set minimum price floor for each ad type. Ads with eCPM lower then price floor will not be filled.
  • Overriden eCPM. Allows you to override eCPM of each network for ad type. High eCPM(100+) will ensure that the network will be at the top of the waterfall and get the first fill. Low eCPM (close to 0) will ensure that the network acts as backfill

If you have no segments, all users will be matched to hidden default segment.

If you have multiple segments, their order is important. Only the first segment in which rules are matched to the user will apply. All of the rest will be ignored.

Placements

Appodeal SDK allows you to tag each impression with different placement.

To show an ad with placement, you have to call show method like this:

Appodeal.showWithPlacement(adTypes, placementName);

To check if ad can be shown for the specific placement use:

Appodeal.canShowWithPlacement(adTypes, placementName, function(result) {
    if(result) { // returns true or false 
        // your code
    }
});

Placement can be used for separating your revenue by placement in our dashboard and determining which placement earns you more money.

Also you can configure your impression logic for each placement. You can use the following Placement settings:

  • Disable ads - disables ads completely for that placement
  • Disable as types - disables specific ad type for a placement. If you integrated to show Appodeal.INTERSTITIAL | Appodeal.SKIPPABLE_VIDEO you can disable interstitials or skippable video for the placement
  • Reward - you can set a reward amount and name which will be passed in onRewardedVideoFinished callback for all videos shown with this placement
  • Impression/Refresh period - you can set impression period (in seconds) for interstitials, skippable and rewarded video shown with the placement. If the period between two impression is less than impression period second impression will not be shown and Appodeal.show method will return false. For banners and MRECs you can set their refresh period
  • Min pricefloor - Allows you to set minimum price floor for each ad type. Ads with eCPM lower then price floor will not be shown and Appodeal.show method will return false.

Placements can only be used as part of existing segment. If you only want to use placements, create one segment for each platform without any rules and match rule ALL. All of your users will match to it.

If you have no placement, or call Appodeal.show with placement that do not exist or without placement in your segment, the impression will be tagged with 'default' placement and its settings will be applied

You can check more examples here

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 { *; }

Third-party SDKs versions

NetworkAndroid SDK versioniOS SDK version
Adcolony3.1.23.0.6
Admob9.8.07.21.0
Amazon Ads5.8.1.12.2.15
Applovin7.3.24.3.1
Appnext2.0.3.459Not Supported
Chartboost6.6.36.6.1
Facebook Audience Network4.25.04.24.0
Flurry7.0.08.0.1
Inmobi6.2.36.2.1
IronSource6.6.2.16.4.21
myTarget4.6.174.6.16
Mopub4.15.04.15.0
Ogury2.1.15Not Supported
Startapp3.6.23.4.3
Tapjoy11.11.011.11.0
Unity Ads2.1.02.1.0
Vungle5.1.05.1.0
Yandex Metrica2.732.7.0
Yandex Mobile Ads2.602.7.0