Standard SDK 8.11

From docs.airpush.com
Jump to: navigation, search

Contents

Overview

Premium-image.png

Airpush's Standard SDK allows developers to earn industry-leading advertising CPM revenue with the world's highest global fill rates.

  • Advanced in-app banner ad units with 360 Banner, including new Abstract Banners.
  • Interstitial ad type mediation with SmartWall.
  • Free Weekly Payments.

Package Name

Your Airpush Package Name : <your package name>

Ad Units

360b horizontal logo.png

360 banner gif 040715 wiki docs.gif Hd video gif 021815 wiki docs.gif

360 Banner includes Abstract Banners, HD Video
Abstracts, and IAB Standard Banner formats.
SMARTWALL
360interstitial.gif
SmartWall includes Video,
Rich Media, AppWall, Dialog,
and Overlay formats.

To enable and optimize each of these ad units, select the corresponding check box next to each ad unit in 'Step 2' of adding your app. Free weekly payments are available for each.

360 Banner

360 Banner reinvents the traditional in-app banner placement, automatically mediating between Abstract Banners, HD Video Abstracts and Traditional Banners. This results in a greater user experience and a huge increase in developer earnings.

  • Higher earnings than any other banner placement.
  • One integration powers multiple ad types.
  • Uses traditional IAB banner size placements.
  • Ensures a quality user experience.
Airpush's Revolutionary Abstract Banners included in 360 Banner
The banner is back! Drive 2-5x more earnings than traditional banners with Airpush’s new Abstract Banners. These innovative and deeply engaging ad formats seamlessly blend full motion transparent overlays with app content and result in dramatically higher earnings than any other banner format.
  • 2x-5x standard banner earnings
  • Gorgeous, closable, animated ads
  • Deep publisher controls
  • 100% high quality ads
  • Free weekly payments
NEW - Airpush's Revolutionary HD Video Abstracts included in 360 Banner
  • Seamless playback
  • A superior user experience
  • Higher earnings than any other video solution

Earnings comparison button.PNG

SmartWall

SmartWall automatically mediates between Rich Media, Video, AppWall, Dialog Ads, Advanced Overlays, Landing Page and more based on yield and network connection type!

  • Higher earnings than any other interstitial.
  • One integration powers multiple ad types.
  • The only interstitial you’ll ever need.
  • Ensures a quality user experience.

Installation Instructions

The Standard SDK contains the code necessary to install Airpush ads within your application. This wiki will guide you through a simple XML implementation.

Airpush Standard SDK Requirements:

  1. JDK 1.6 or later
  2. Android 2.3 or later
  3. Google Play Services SDK

Note: You need to use Android 5.1 (API level 22) or below version to compile your app. This version is not yet compatible with Android 6.0 (API level 23). However apps compiled using Android 5.1 or below API work fine on Android 6.0 devices.

Step 1 - Adding the JAR

For Eclipse Projects:

Copy the <your Airpush SDK>.jar to the "libs" folder of your project and move on to step 2.


Jar1.png


To verify whether it's added to your project, expand "Android Dependencies:"


Jar2.png

Step 2 - Google Play Services SDK

Please follow the steps found here: https://developer.android.com/google/play-services/setup.html#Install to add the Google Play Services SDK in your project.

Step 3 - Editing Your Manifest File

First you'll need to note your Airpush <App Id> and <API Key>, which was given to you when registering your Android application on www.airpush.com. It's a numeric code that can be found by locating your app in the apps dashboard:


Appidnew.png


Just before the closing </application> tag of your AndroidManifest.xml file, you'll need to add the following:

1. Copy and paste the following XML

Placed just before the closing </application> tag:

Required declaration for all ads
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

<activity android:exported="false" android:name="<your package name>.AdActivity"
     android:configChanges="orientation|screenSize"
android:theme="@android:style/Theme.Translucent" />

<activity android:name="<your package name>.BrowserActivity"
android:configChanges="orientation|screenSize" />

2. Add The Following Permissions

Required permissions for all ads
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Optional permissions:

**We strongly recommend you add the optional permissions below to enhance your earnings potential.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Step 4 - Editing Your Main File

Inside "Activity," please add:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

//Add import statements
import <your package name>.AdConfig;
import <your package name>.AdConfig.AdType;
import <your package name>.AdView;
import <your package name>.AdListener;  
import <your package name>.Main;

public class MainActivity extends Activity  implements AdListener{

private Main main; //Declare here

@Override
protected void onCreate(Bundle savedInstanceState)
{
     super.onCreate(savedInstanceState);
     AdConfig.setAppId(29011);  //setting appid. 
     AdConfig.setApiKey("1345103177648703821"); //setting apikey
     AdConfig.setAdListener(this);  //setting global Ad listener. 
     AdConfig.setCachingEnabled(true); //Enabling SmartWall ad caching. 
     AdConfig.setPlacementId(0); //pass the placement id.
     setContentView(R.layout.activity_main);

   //Initialize Airpush 
    main=new Main(this); 

   //for calling banner 360
    main.start360BannerAd(this);    

   //for calling Smartwall ad
    main.startInterstitialAd(AdType.smartwall); 

}

Where,

AdConfig.setAppId(int appid); A unique id for your app that can be obtained from Airpush portal once you add your app in console. Please make sure you replace “<appid>” with the unique ID provided in Airpush portal.
AdConfig.setApiKey(String API_key); API Key is unique to each developer. It can be obtained from Aiprush portal.
AdConfig.setTestMode(boolean testmode); You can utilize our test mode to test our Banner 360 ads and SmartWall ads in your app by switching testmode to true. Please note this mode only serves the test ads and doesn't earn you any revenue. Its designed only for the testing the integration. Please ensure test mode value is turned to false before you push Airpush code live post testing.
AdConfig.setCachingEnabled(boolean enableCaching); Ad Caching: If you are showing ads on app exit (for example: when the back button is pressed), we highly recommend to use the ad caching feature to ensure the ads are only shown within your app.

How caching works: Ad caching feature reduces the total turn around time to show the ad so that it can be rendered in fraction of milliseconds. When we call main.startInterstitialAd(AdType.smartwall); , SDK fetches new ad from ad server and store it locally. For rendering the cached ad we need to call showCachedAd(AdType.smartwall). SDK clears the cache once its finished ad rendering so on next ad call it can store another ad. SDK discards the new ad call request if an ad is already available in cache. For more details please refer to Ad caching section

AdConfig.setPlacementId(int placement_id); placement_id: It can be used by a developer to show/block a particular sub format on a given placement id from the portal. We highly recommend using placement ids for controlling the sub formats to be shown for a particular placement id from portal itself. Placement id is a integer value between 0 and 100. Default value is 0. Placement can be used with Banner 360 ad format only. Please refer to this doc for details: Placement Id Usage.
AdConfig.setAdListener(this); Set the ad callback listeners. For more details please refer to Ad callback listener section.
main.start360BannerAd(Activity activity); If you wish to show Abstract Banner, Standard Banner and Video Ads on the screen, please call the above method in the "onCreate()" of your Activity. Please refer to Banner 360 section
main.startInterstitialAd(AdType.smartwall); This will call Airpush SmartWall ads. Please check the SmartWall section.

Using SmartWall in your application:

Airpush’s SmartWall is comprised of the following six sub Ad Formats:

  1. Dialog Ads
  2. AppWall Ads
  3. Rich Media Interstitial Ads
  4. Video Ads
  5. Overlay Ads
  6. Landing Page Ads

Airpush’s ad server determines and displays the best sub-ad-format to maximize your revenue from Interstitial Ad Placements in your application. You just have to call the “main.startInterstitialAd(AdType.smartwall);” method wherever you want to show Airpush’s Smartwall. For example: in the case of a gaming app, you can call "main.startInterstitialAd(AdType.smartwall);" between different levels and show a SmartWall app after a user clears each level. Airpush also offer flexibility for developers to choose a specific sub-ad-format from the above options to display by using the following methods within your code:

  1. To start Overlay Dialog Ad: main.startInterstitialAd(AdType.overlay);
  2. To start AppWall Ad: main.startInterstitialAd(AdType.appwall);
  3. To start Rich Media Interstitial Ad: main.startInterstitialAd(AdType.interstitial);
  4. To start Video Ad: main.startInterstitialAd(AdType.video);

Note: Although developers can choose to display a specific sub-ad-format, we highly recommend using the main.startInterstitialAd(AdType.smartwall);” method which lets the Airpush ad server decide the best sub-format in order to maximize your earnings. We would also recommend showing Smartwall on App Launch and App Exit to maximize monetization. Here's sample code for showing Airpush’s Smartwall on app exit:

If you want to show a SmartWall ad where the sub-format will be determined by SDK, please use the code below:

Example: Ad caching enabled

@Override
public void onBackPressed() {
   try{
     main.showCachedAd(AdType.smartwall);   //This will display the ad but it wont close the app. 
   }catch (Exception e) {
     // close the activity if ad is not available. 
     finish();
   }
}

Ad Caching Example

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

//Add import statements
import <your package name>.AdConfig;
import <your package name>.AdConfig.AdType;
import <your package name>.AdView;
import <your package name>.AdListener;  
import <your package name>.Main;

public class MainActivity extends Activity  implements AdListener{

private Main main; //Declare here

@Override
protected void onCreate(Bundle savedInstanceState)
{
      super.onCreate(savedInstanceState);
      AdConfig.setAppId(29011);  
      AdConfig.setApiKey("1345103177648703821");
      AdConfig.setAdListener(this); 
      AdConfig.setCachingEnabled(true); 
      AdConfig.setPlacementId(0); 

      setContentView(R.layout.activity_main);

      main=new Main(this); 
      main.startInterstitialAd(adType); 

}


@Override
public void onBackPressed() {


try {
      //Displaying Cached SmartWall Ad
      main.showCachedAd(AdType.smartwall);
    } catch (Exception e) 
     {
      super.onBackPressed();
     }
}


Note: You can use caching for Smartwall ad formats only. Please use the above mentioned steps for caching.

Using 360 Ad in your application:

For placement usage please refer to the following link for details: Placement Id Usage.

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

//Add import statements
import <your package name>.AdConfig;
import <your package name>.AdConfig.AdType;
import <your package name>.AdView;
import <your package name>.AdListener;  
import <your package name>.Main;

public class MainActivity extends Activity  implements AdListener{

private Main main; //Declare here

@Override
protected void onCreate(Bundle savedInstanceState)
{
      super.onCreate(savedInstanceState);
      AdConfig.setAppId(29011);
      AdConfig.setApiKey("1345103177648703821");
      AdConfig.setAdListener(this);
      AdConfig.setCachingEnabled(true);
      AdConfig.setPlacementId(0); 
      setContentView(R.layout.activity_main);

   //initialize Airpush
    main=new Main(this); //Here this is reference of current Activity. 

   //for calling banner 360
    main.start360BannerAd(this);  //pass the current Activity's reference.

}

5. AdCallbackListener:

Ad callback listeners is present for all the ads, which can be called using the code below:


     @Override
     protected void onCreate(Bundle savedInstanceState)
     {
        super.onCreate(savedInstanceState);
         
        AdConfig.setAdListener(adListener);
        setContentView(R.layout.actvity_main);

     }

AdListener adListener=new AdListener() {
		
 @Override
 public void onIntegrationError(String errorMessage) {
  //This will get called when any error has occurred. This will also get called if the SDK notices any integration mistakes.
			
}
		
@Override
public void onCloseListener() {
//This will get called when an ad is closing/resizing from an expanded state.
			
}
		
@Override
public void onAdShowing() {
 // This will be called by SDK when it’s showing any of the SmartWall ad.
			
}
		
@Override
public void onAdLoadingListener() {
 //This will get called when a rich media ad is loading.
			
}
		
@Override
public void onAdLoadedListener() {
  //This will get called when an ad has loaded.
			
}
		
@Override
public void onAdExpandedListner() {
 //This will get called when an ad is showing on a user's screen. This may cover the whole UI.
			
}
		
@Override
public void onAdError(String errorMessage) {
//This will get called if any error occurred during ad serving.
			
}
		
@Override
public void onAdClosed() {
// This will be called by SDK when the SmartWall ad is closed.
			
}
		
@Override
public void onAdClickedListener() {
 //This will get called when ad is clicked.
			
}
		
@Override
public void onAdCached(AdType adType) {
//This will get called when an ad is cached. 
			
}
		
@Override
public void noAdListener() {
 //this will get called when ad is not available 
			
 }
};

Step 6 - Inline Banner Ads

Banner ads includes Medium Rectangle banner and IAB MRAID 2.0 compliant Rich Media banner ads. To show these ads in your app, you'll need to add the following entry into your layout.xml file (app's layout file).

<<your package name>.AdView
android:id="@+id/myAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />

Now add the below code in your Activity's onCreate().


AdView adView=(AdView) findViewById(R.id.myAdView);

 adView.setBannerType(AdView.BANNER_TYPE_IN_APP_AD);
 adView.setBannerAnimation(AdView.ANIMATION_TYPE_FADE);
 adView.showMRinInApp(false);
 adView.setNewAdListener(this);
 adView.loadAd(); 
 

Where,

adView.setBannerType(AdView.BANNER_TYPE_IN_APP_AD); Set the inline banner type, available banner types are AdView.BANNER_TYPE_IN_APP_AD, AdView.BANNER_TYPE_RICH_MEDIA and AdView.BANNER_TYPE_MEDIUM_RECTANGLE . Default is AdView.BANNER_TYPE_IN_APP_AD.
adView.setBannerAnimation(AdView.ANIMATION_TYPE_FADE); Set the animation type for inline banner ads. Available animation types are AdView.ANIMATION_TYPE_FADE, AdView.ANIMATION_TYPE_LEFT_TO_RIGHT and AdView.ANIMATION_TYPE_TOP_DOWN . Default is AdView.ANIMATION_TYPE_FADE.
adView.setNewAdListener(this); Use this method to set a new listener for inline banner ad. For more details please refer to the Ad CallbackListener section. If you do call this method and AdConfig.setAdListener(this); already called then SDK will use AdConfig's callback listener.
adView.loadAd(); Call this method to load inline banner ads.

Example:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

//Add import statements
import <your package name>.AdConfig;
import <your package name>.AdConfig.AdType;
import <your package name>.AdView;
import <your package name>.AdListener;  
import <your package name>.Main;
import <your package name>.AdView;


public class MainActivity extends Activity{

private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
     super.onCreate(savedInstanceState);
     AdConfig.setAppId(29011);  //setting appid. 
     AdConfig.setApiKey("1345103177648703821"); //setting apikey
         
     setContentView(R.layout.activity_main);


     adView=(AdView) findViewById(R.id.myAdView);
     adView.setBannerType(AdView.BANNER_TYPE_IN_APP_AD);
     adView.setBannerAnimation(AdView.ANIMATION_TYPE_FADE);
     adView.showMRinInApp(false);
     adView.setNewAdListener(adListener); //for passing a new listener for inline banner ads. 
     adView.loadAd();
}


AdListener adListener=new AdListener() {
		
 @Override
 public void onIntegrationError(String errorMessage) {
  //This will get called when any error has occurred. This will also get called if the SDK notices any integration mistakes.
			
}
		
@Override
public void onCloseListener() {
//This will get called when an ad is closing/resizing from an expanded state.
			
}
		
@Override
public void onAdShowing() {
 // This will be called by SDK when it’s showing any of the SmartWall ad.
			
}
		
@Override
public void onAdLoadingListener() {
 //This will get called when a rich media ad is loading.
			
}
		
@Override
public void onAdLoadedListener() {
  //This will get called when an ad has loaded.
			
}
		
@Override
public void onAdExpandedListner() {
 //This will get called when an ad is showing on a user's screen. This may cover the whole UI.
			
}
		
@Override
public void onAdError(String errorMessage) {
//This will get called if any error occurred during ad serving.
			
}
		
@Override
public void onAdClosed() {
// This will be called by SDK when the SmartWall ad is closed.
			
}
		
@Override
public void onAdClickedListener() {
 //This will get called when ad is clicked.
			
}
		
@Override
public void onAdCached(AdType adType) {
//This will get called when an ad is cached. 
			
}
		
@Override
public void noAdListener() {
 //this will get called when ad is not available 
			
 }
};


Use banner ads using Java code

/* AdView Class is same as View Class. You can use the Adview object as View object. */
   adView=new AdView(this);
   adView.setBannerType(AdView.BANNER_TYPE_IN_APP_AD);
   adView.setBannerAnimation(AdView.ANIMATION_TYPE_FADE);
   adView.showMRinInApp(false);
   adView.setNewAdListener(adListener);
   adView.loadAd();

Note: You need to add the adView to your view before calling adView.loadAd();. Please check Bundled SDK test project for more details.

Step 7- Using Proguard

Keep options required for Standard SDK 8.11
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:


-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*

-injars      bin/classes
-injars      libs
-outjars     bin/classes-processed.jar

-keep public class * extends android.app.Activity 
-keep public class * extends android.app.Application 
-keep public class * extends android.app.Service 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider  
-keep public class * extends android.preference.Preference
-keep class <your package name>.** {*;}
-dontwarn <your package name>.**



-keepclasseswithmembernames class * 
 {
    native <methods>;
 }

 -keepclasseswithmembers class * 
  {
    public <init>(android.content.Context, android.util.AttributeSet);
  }

 -keepclasseswithmembers class * 
  {
    public <init>(android.content.Context, android.util.AttributeSet, int);
  }

  -keepclassmembers enum * 
  {
    public static **[] values();
    public static ** valueOf(java.lang.String);
  }



  -keep class * implements android.os.Parcelable 
   {
     public static final android.os.Parcelable$Creator *;
   }

   -keepclasseswithmembers class **.R$** 
   {
    public static <fields>;
   }

  -keepclassmembers class * 
  {
    @android.webkit.JavascriptInterface <methods>;
  }
   -keep 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); 
	  void set*(***);
	   *** get*();
    }

   -keepclassmembers class * 
    {
	    static final %                *;
	    static final java.lang.String *;
    }

#add the following for Google play services.
-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 @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

-keep class com.google.android.gms.**
-dontwarn com.google.android.gms.**

#Google play services declarations ends

-keepattributes SetJavaScriptEnabled
-keepattributes JavascriptInterface
-keepattributes InlinedApi

	

Important Instructions

  • For the best experience, please use the latest Android API as the build target.
  • If you are upgrading/updating the SDK, please don't forget to clean & build the project after completing all steps successfully.
  • Please enable the Smartwall ad type for your application under your account within the Airpush Portal to utilize our Interstitial Ads.

Official Airpush Plugins for Game Engines

Package downloads and documentation on all available plugins are available here.

Sample Application Code and Support:

You can download the demo project "Standard demo" using the following link http://manage.airpush.com/sdk/StandardDemo.zip. This is code demonstration on 'How to integrate Airpush Standard SDK' in your app.If you face any issues integrating SDK with your app please feel free to drop an email to publishersupport@airpush.comand our support team will get them resolved asap.

Personal tools
Namespaces

Variants
Actions
Toolbox