The YaftaMobile Native Extension enables developers to quickly integrate YaftaMobile ads into their Adobe AIR mobile applications. The SDK supports android 2.3 or higher.
First, import the YaftaMobile native extension into your AIR app. We recommend creating a directory in your project for native extensions, and copy YaftaMobile.ane to that directory. Then add that directory as a native extension directory in your project settings
If you are using Flash Builder, follow these steps:
For YaftaMobile to work, you need to make the following changes in the app descriptor manifest file.
INTERNET
, ACCESS_NETWORK_STATE
com.yaftamobile.sdk.app.id
, with a value of your AppIDInterstitialActivity
Your App Descriptor should have the following:
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<!-- These permissions are required for YaftaMobile. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
<!-- The app ID must be placed here. -->
<meta-data android:name="com.yaftamobile.sdk.app.id"
android:value="YOUR-APPID" />
<!-- Only required for interstitials -->
<activity android:configChanges="keyboard|keyboardHidden|orientation"
android:name="com.yaftamobile.sdk.ads.interstitial.InterstitialActivity" />
<!-- For Google Play Services (required by YaftaMobile) -->
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
]]></manifestAdditions>
<extensions>
<extensionID>com.yaftamobile.plugins.air</extensionID>
</extensions>
To display banner ads in your app use the showBanner(adSize:AdSize, bannerPosition:BannerPosition, refreshRate:int)
method where:
FLEXIBLE
, S300X50
, S320X50
, S468X60
, S728X90
TOP_CENTER
, TOP_LEFT
, TOP_RIGHT
, BOTTOM_CENTER
, BOTTOM_LEFT
, BOTTOM_RIGHT
Before you can use YaftaMobile native extension in your code, you need the following import declaration:
import com.yaftamobile.plugin.air.*;
Add the following code to show banner:
YaftaMobile.showBanner(AdSize.FLEXIBLE, BannerPosition.BOTTOM_CENTER , 60);
Use the following to hide/re-show the banner:
YaftaMobile.pauseBanner(); // hide banner if visible
YaftaMobile.resumeBanner(); // show banner if not visible
To show an interstitial ad you need to load it first using the loadInterstitial()
method, then if loaded successfuly, call the method showInterstitial() to show the ad on the screen.
You can detect if an interstitial has been loaded and is ready to be displayed by listening to the INTERSTITIAL_LOADED
event.
Here is sample code showing the two-step process for showing the interstitial ad:
...
// Register listener for INTERSTITIAL_LOADED event
YaftaMobile.addEventListener(AdEvent.INTERSTITIAL_LOADED,onInterstitialLoaded);
...
// Request an interstitial ad
YaftaMobile.loadInterstitial();
.....
// Show the interstitial ad
protected function onInterstitialLoaded(ev:AdEvent):void{
YaftaMobile.showInterstitial();
}
The YaftaMobile SDK emits events that let you know what happens during the ad life-cycle. To listen to ad events, you need to call the addEventListener(type:String, listener:Function)
method where
The available ad events to listen to are listed below:
//Fired when an ad is successfully loaded.
public static const AD_LOADED:String = "onAdLoaded";
//Fired when an ad is clicked.
public static const AD_CLICKED:String = "onAdClicked";
//Fired when a failure occurred during ad loading.
public static const AD_ERROR:String = "onAdError";
//Fired when an interstitial ad is loaded.
public static const INTERSTITIAL_LOADED:String = "onInterstitialLoaded";
//Fired when an interstitial ad is clicked.
public static const INTERSTITIAL_CLICKED:String ="onInterstitialClicked";
//Fired when a failure occurred during interstitial ad loading.
public static const INTERSTITIAL_ERROR:String ="onInterstitialError";
//Fired when an interstitial ad is closed.
public static const INTERSTITIAL_DISMISSED:String ="onInterstitialDismissed";
The SDK Integration can be tested by enabling test mode to verify that the set up SDK side has been completed correctly. You can enable test mode using the setTestMode(boolean testMode)
method
Use the following to enable test mode:
YaftaMobile.setTestMode(true);