Download & Integrate the Chartboost SDK for Adobe AIR

Last Update:

 

Add your mobile game to the Chartboost network with just 10 lines of code!

 

Download SDK How to Integrate
v6.6.3 | How big is the SDK?  

 

Release Notes

 


 

What's in the box? Our SDK package comes fully loaded with features.

High-quality video ads specially tailored for games to reward your players!

Customizable interstitials that give your players a seamless in-game experience!

A robust analytics suite to target your best possible audience!

View full SDK release notes ▶

 


 

Ready to integrate the Chartboost SDK? Let's do this!

 


 

 

Before you begin:

Adding the AIR plugin to your games is quick and easy – you just need a few ingredients:

  • A Chartboost account
  • An app in your dashboard
  • The latest AIR plugin
  • An active publishing campaign
  • The Chartboost Adobe AIR plugin is currently in beta.
  • The plugin uses iOS SDK v6.4.7 and Android SDK v6.4.2.
  • The Chartboost AIR plugin supports iOS 6 and higher and Android 2.3 and higher.
  • Requires -swf-version 33 compiler flag. In Flash Builder, this is entered under Project properties > Flex Compiler > Additional compiler arguments.
  • Requires AIR SDK version 22 or higher.

 

 

Import the Chartboost native extension into your AIR app.

We recommend creating a directory in your project for native extensions where you can copy Chartboost.ane and Chartboost.swc. Then (if you're using Flash Builder) you can simply add that directory as a native extension directory in your project settings.

 


 

Add the <extensionID> declaration to your AIR application descriptor's root <application> element.

<extensions>
    <extensionID>com.chartboost.plugin.air</extensionID>
</extensions>

If you'll be building for Android, you must also add these manifest additions to your AIR application descriptor file (remember to swap in your Chartboost app ID and app signature):

<manifestAdditions><![CDATA[
    <manifest android:installLocation="auto">
        <!-- This permission is required for Chartboost. -->
        <uses-permission android:name="android.permission.INTERNET"/>
        
        <!-- These permissions are recommended for Chartboost. -->
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
		<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
		<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
		<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
        
        <application>
            <!-- The app ID and signature for the Android version of your AIR app must be placed here. -->
            <meta-data android:name="__ChartboostAir__AppID" android:value="ANDROID_APP_ID" />
            <meta-data android:name="__ChartboostAir__AppSignature" android:value="ANDROID_APP_SIGNATURE" />
            
            <!-- Also required for the Chartboost SDK. -->
            <activity android:name="com.chartboost.sdk.CBImpressionActivity"
									  android:excludeFromRecents="true" 
                                      android:hardwareAccelerated="true"
                                      android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
                                      android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" />
                                      
            <!-- For Google Play Services (required by Chartboost) -->
            <meta-data android:name="com.google.android.gms.version"
                                      android:value="@integer/google_play_services_version" />
        </application>
    </manifest>
]]></manifestAdditions>

Android developers: Note also that if you are using another plugin that includes Google Play Services, you may get an error while building. Use the provided ANE that is free of Google Play Services if you want to avoid this conflict.

 


 

Import the Chartboost classes.

import com.chartboost.plugin.air.*;

 


 

Initialize Chartboost.

Call the startWith() method with the AIR application stage and your Chartboost app ID and app signature. You'll probably need to call the method conditionally for different platforms, so we've provided some helper functions for you to use:

if (Chartboost.isAndroid()) {
    Chartboost.startWith(stage, "ANDROID_APP_ID", "ANDROID_APP_SIGNATURE");
} else if (Chartboost.isIOS()) {
    Chartboost.startWith(stage, "IOS_APP_ID", "IOS_APP_SIGNATURE");
}
You must initialize Chartboost so we can record bootups for your game. If you do not initialize Chartboost, you will not be eligible to run advertising campaigns.
startWith() must always be called during hard and soft bootups within the first few seconds of your app launching, regardless of any other actions or user interaction within your app.

 


 

To show a static or video interstitial:

Chartboost.showInterstitial(CBLocation.DEFAULT);
  • You can use the CBLocation interface class to get a list of default location constants as well as define your own.  Once a location is used, it will be added to your dashboard, where you can customize its settings.
  • For customized control over how ads behave in your game, the Chartboost SDK also offers more features such as caching, delegate methods, and named locations.
  • Learn more about Chartboost video ads ▶
Do not call showInterstitial directly after cacheInterstitial for the same location, or the SDK will fail silently.
We strongly recommend that you cache your interstitials before showing them. Learn more about caching ▶
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

 

To show a rewarded video ad:

Chartboost.showRewardedVideo(CBLocation.DEFAULT);
  • You can use the CBLocation interface class to get a list of default location constants as well as define your own.  Once a location is used, it will be added to your dashboard, where you can customize its settings.
  • For customized control over how ads behave in your game, the Chartboost SDK also offers more features such as caching, delegate methods, and named locations.
  • Learn more about Chartboost video ads ▶
Do not call showRewardedVideo directly after cacheRewardedVideo for the same location, or the SDK will fail silently.
We strongly recommend that you cache your interstitials before showing them. Learn more about caching ▶
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

 

To call Chartboost methods:

In /actionscript/src/com/chartboost/plugin/air/Chartboost.as, you'll find the AIR-to-native methods used to interact with the Chartboost plugin:

/** Initializes the Chartboost plugin */
public static function startWith(stage:Stage, appID:String, appSignature:String):void

/** Listen to a delegate event from the ChartboostEvent class. See the documentation
* of the event you choose for the arguments and return value of the function you provide. */
public static function addDelegateEvent(eventName:String, listener:Function):void

/** Caches an interstitial. */
public static function cacheInterstitial(location:String):void

/** Shows an interstitial. */
public static function showInterstitial(location:String):void

/** Checks to see if an interstitial is cached. */
public static function hasInterstitial(location:String):Boolean

/** Caches the rewarded video. */
public static function cacheRewardedVideo(location:String):void

/** Shows the rewarded video. */
public static function showRewardedVideo(location:String):void

/** Checks to see if the rewarded video is cached. */
public static function hasRewardedVideo(location:String):Boolean

/** Caches an in-play ad. */
public static function cacheInPlay(location:String):void

/** Gets the cached InPlay ad.
* This is an asynchronous operation, so instead of returning a CBInPlay object,
*  it is passed to the Function provided when ready.
* If there is no in-play ad available, the Function provided is not called.
* The function provided should have one argument, a CBInPlay object. See the provided sample app for a usage demonstration. */
public static function getInPlay(location:String, fn:Function):void

/** Checks to see if an in-play ad is cached. */
public static function hasInPlay(location:String):Boolean

/** Call this as a result of whatever UI you show in response to the
* delegate method didPauseClickForConfirmation() */
public static function didPassAgeGate(pass:Boolean):void

/** Custom settings */
public static function setCustomID(customID:String):void
public static function getCustomID():String

/** Set whether interstitials will be requested in the first user session */
public static function setShouldRequestInterstitialsInFirstSession(shouldRequest:Boolean):void

/** Set whether or not to use the age gate feature.
* Call Chartboost.didPassAgeGate() to provide your user's response. */
public static function setShouldPauseClickForConfirmation(shouldPause:Boolean):void

/** Set whether video content is prefetched */
public static function setShouldPrefetchVideoContent(shouldPrefetch:Boolean):void

/** Control whether ads are automatically cached when possible (default: true). */
public static function setAutoCacheAds(shouldCache:Boolean):void
public static function getAutoCacheAds():Boolean

/** Chartboost in-app purchase analytics */
public static function trackIOSInAppPurchaseEvent(receipt:String, title:String, description:String, price:Number, currency:String, productID:String):void
public static function trackGooglePlayInAppPurchaseEvent(title:String, description:String, price:String, currency:String, productID:String, purchaseData:String, purchaseSignature:String):void
public static function trackAmazonStoreInAppPurchaseEvent(title:String, description:String, price:String, currency:String, productID:String, userID:String, purchaseToken:String):void

/** Chartboost post install analytics */
public static function trackLevelInfoEvent(eventLabel:String, eventField:CBLevelType, mainLevel:int, subLevel:int, description:String):void

/** iOS only: Set how Chartboost interacts when the status bar is present. (default: Ignore). */
public static function setStatusBarBehavior(statusBarBehavior:CBStatusBarBehavior):void

/** Get whether any ad is visible on the screen. */
public static function isAnyViewVisible():Boolean

/** Close any impression that is open. Returns if successful on iOS, always returns true on Android. */
public static function closeImpression():Boolean

/** Returns whether IAPs are automatically tracked. iOS only. */
public static function getAutoIAPTracking():Boolean

/** Returns whether webview is enabled (server setting). Android only. */
public static function isWebViewEnabled():Boolean

/** Sets whether the system UI is hidden during impressions. Android only. */
public static function setShouldHideSystemUI(shouldHide:Boolean):void

/** For wrappers only: set the mediation service used */
public static function setMediation(mediator:CBMediation, version:String):void

 


 

Listening to Chartboost events:

Chartboost fires many different events to inform you of the status of impressions. In order to react these events, you must explicitly listen for them. The best place to do this is the initialization code for your active screen:

// in some initializing code
chartboost.addDelegateEvent(ChartboostEvent.DID_CLICK_INTERSTITIAL, function (location:String):void {
    trace( "Chartboost: on Interstitial clicked: " + location );
});

In /actionscript/src/com/chartboost/plugin/air/ChartboostEvent.as, you'll find all the events that are available to listen to:

  
/** Fired after the SDK has been successfully initialized. Implement to be notified of when the initialization process has finished.
* Arguments: (status:Boolean) */
public static const DID_INITIALIZE:String = "didInitialize";

/** Fired when an interstitial fails to load.
* Arguments: (location:String, error:CBLoadError) */
public static const DID_FAIL_TO_LOAD_INTERSTITIAL:String = "didFailToLoadInterstitial";

/** Fired when an interstitial is to display. Return whether or not it should.
* Arguments: (location:String)
* Returns: Boolean */
public static const SHOULD_DISPLAY_INTERSTITIAL:String = "shouldDisplayInterstitial";

/** Fired when an interstitial is finished via any method.
* This will always be paired with either a close or click event.
* Arguments: (location:String) */
public static const DID_CLICK_INTERSTITIAL:String = "didClickInterstitial";

/** Fired when an interstitial is closed
* (i.e. by tapping the X or hitting the Android back button).
* Arguments: (location:String) */
public static const DID_CLOSE_INTERSTITIAL:String = "didCloseInterstitial";

/** Fired when an interstitial is clicked.
* Arguments: (location:String) */
public static const DID_DISMISS_INTERSTITIAL:String = "didDismissInterstitial";        

/** Fired when an interstitial is cached.
* Arguments: (location:String) */
public static const DID_CACHE_INTERSTITIAL:String = "didCacheInterstitial";

/** Fired when an interstitial is shown.
* Arguments: (location:String) */
public static const DID_DISPLAY_INTERSTITIAL:String = "didDisplayInterstitial";

/** Fired after a click is registered, but the user is not forwarded to the IOS App Store.
* Arguments: (location:String, error:CBClickError) */
public static const DID_FAIL_TO_RECORD_CLICK:String = "didFailToRecordClick";

/** Fired when a rewarded video is cached.
* Arguments: (location:String) */
public static const DID_CACHE_REWARDED_VIDEO:String = "didCacheRewardedVideo";

/** Fired when a rewarded video is clicked.
* Arguments: (location:String) */
public static const DID_CLICK_REWARDED_VIDEO:String = "didClickRewardedVideo";

/** Fired when a rewarded video is closed.
* Arguments: (location:String) */
public static const DID_CLOSE_REWARDED_VIDEO:String = "didCloseRewardedVideo";

/** Fired when a rewarded video completes.
* Arguments: (location:String, reward:int) */
public static const DID_COMPLETE_REWARDED_VIDEO:String = "didCompleteRewardedVideo";

/** Fired when a rewarded video is dismissed.
* Arguments: (location:String) */
public static const DID_DISMISS_REWARDED_VIDEO:String = "didDismissRewardedVideo";

/** Fired when a rewarded video fails to load.
* Arguments: (location:String, error:CBLoadError) */
public static const DID_FAIL_TO_LOAD_REWARDED_VIDEO:String = "didFailToLoadRewardedVideo";

/** Fired when a rewarded video is to display. Return whether or not it should.
* Arguments: (location:String)
* Returns: Boolean */
public static const SHOULD_DISPLAY_REWARDED_VIDEO:String = "shouldDisplayRewardedVideo";

/** Fired right after a rewarded video is displayed.
* Arguments: (location:String) */
public static const DID_DISPLAY_REWARDED_VIDEO:String = "didDisplayRewardedVideo";

/** Fired when a video is about to be displayed.
* Arguments: (location:String) */
public static const WILL_DISPLAY_VIDEO:String = "willDisplayVideo";

/** Fired if Chartboost plugin pauses click actions awaiting confirmation from the user.
* Arguments: None */
public static const DID_PAUSE_CLICK_FOR_COMFIRMATION:String = "didPauseClickForConfirmation";

/** iOS only: Fired when the App Store sheet is dismissed, when displaying the embedded app sheet.
* Arguments: None */
public static const DID_COMPLETE_APP_STORE_SHEET_FLOW:String = "didCompleteAppStoreSheetFlow";
Don't make cache or show calls inside didFailToLoad delegates or the universe will implode.

 


 

Test your integration.

To test the setup, start a publishing campaign, add the app you've been integrating with the plugin to the campaign, then build your project to a device.

If you can see Chartboost test interstitials where you've called for them in your code, you're good to go! Be sure to disable Test Mode (from the App Settings page) so you can see actual network ads:

 


 

w00t! You just integrated the Chartboost SDK into your app!

Now you can start a campaign ▶

 


 

Check out more Chartboost SDK features

  • Caching: Speed up load times for ads by storing them locally on devices.
  • Chartboost Video: Add beautiful, high-quality video ads to give players the best in-game experience.
  • Named locations: Fine-tune your campaign targeting and ad frequency from the dashboard.
  • Post-Install Analytics: For games with in-app purchases. Unlock useful data about players' buying behavior to optimize campaigns or retargeting.
  • Mediation: Show your ads along a waterfall of other top-quality networks.

 


 

You might also like...