Air
Source for the Adobe AIR native extension for the Chartboost SDK with compile scripts.
Install / Use
/learn @ChartBoost/AirREADME
<!-- 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"/>
<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:theme="@android:style/Theme.Translucent.NoTitleBar"
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> </pre>
<p>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.</p> <hr /> <h3 id="int">Interacting With Chartboost</h3> <h5>Chartboost Setup</h5> <p>First, import the Chartboost classes:</p> <pre class="prettyprint">import com.chartboost.plugin.air.*; </pre> <p>We recommend making a variable in your class to store a reference to the global Chartboost instance:</p> <pre class="prettyprint">private var chartboost:Chartboost;// later... chartboost = Chartboost.getInstance(); </pre>
<p>To initialize Chartboost, call the <code>init()</code> method with your Chartboost app ID and app signature. You'll probably need to call it conditionally for different platforms, so we've provided some helper functions for you to use:</p> <pre class="prettyprint">if (Chartboost.isAndroid()) { chartboost.init("ANDROID_APP_ID", "ANDROID_APP_SIGNATURE"); } else if (Chartboost.isIOS()) { chartboost.init("IOS_APP_ID", "IOS_APP_SIGNATURE"); } </pre> <h5>Calling Chartboost Methods</h5> <p>In <code>/actionscript/src/com/chartboost/plugin/air/Chartboost.as</code>, you'll find the AIR-to-native methods used to interact with the Chartboost plugin:</p> <pre class="prettyprint">/** Initializes the Chartboost plugin and, on iOS, records the beginning of a user session */ public function init(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 function addDelegateEvent(eventName:String, listener:Function):void
/** Caches an interstitial. */ public function cacheInterstitial(location:String):void
/** Shows an interstitial. */ public function showInterstitial(location:String):void
/** Checks to see if an interstitial is cached. */ public function hasInterstitial(location:String):Boolean
/** Caches the MoreApps page. */ public function cacheMoreApps(location:String):void
/** Shows the MoreApps page. */ public function showMoreApps(location:String):void
/** Checks to see if the MoreApps page is cached. */ public function hasMoreApps(location:String):Boolean
/** Caches the rewarded video. */ public function cacheRewardedVideo(location:String):void
/** Shows the rewarded video. */ public function showRewardedVideo(location:String):void
/** Checks to see if the rewarded video is cached. */ public function hasRewardedVideo(location:String):Boolean
/** Call this as a result of whatever UI you show in response to the
- delegate method didPauseClickForConfirmation() */ public function didPassAgeGate(pass:Boolean):void
/** Custom settings */ public function setCustomID(customID:String):void public function getCustomID():String
/** Set whether interstitials will be requested in the first user session */ public 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 function setShouldPauseClickForConfirmation(shouldPause:Boolean):void
/** Set whether the MoreApps page will have a full-screen loading view. */ public function setShouldDisplayLoadingViewForMoreApps(shouldDisplay:Boolean):void
/** Set whether video content is prefetched */ public function setShouldPrefetchVideoContent(shouldPrefetch:Boolean):void
/** Control whether ads are automatically cached when possible (default: true). */ public function setAutoCacheAds(shouldCache:Boolean):void public function getAutoCacheAds():Boolean
/** Chartboost in-app purchase analytics */ public function trackIOSInAppPurchaseEvent(receipt:String, title:String, description:String, price:Number, currency:String, productID:String):void public function trackGooglePlayInAppPurchaseEvent(title:String, description:String, price:String, currency:String, productID:String, purchaseData:String, purchaseSignature:String):void public function trackAmazonStoreInAppPurchaseEvent(title:String, description:String, price:String, currency:String, productID:String, userID:String, purchaseToken:String):void
</pre> <h5>Listening to Chartboost Events</h5> <p>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:</p> <pre class="prettyprint">// in some initializing code chartboost.addDelegateEvent(ChartboostEvent.DID_CLICK_INTERSTITIAL, function (location:String):void { trace( "Chartboost: on Interstitial clicked: " + location ); }); </pre> <p>In <code>/actionscript/src/com/chartboost/plugin/air/ChartboostEvent.as</code>, you'll find all the events that are available to listen to:</p> <pre class="prettyprint"> /** 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_INTERSTIT
