AdMob Air Native Extension
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

readme.md

News

2017-11-22: Updated to the latest version of Adobe AIR 27 and Google Play Services 11.0.4. Still working as expected, at least for me. :)

About

ANEAdMob is an Adobe AIR native extension (ANE) for Android to show ads.
Supported functionality:

  • show ad;
  • cache interstitial ad;
  • show interstitial ad;
  • hide ad;
  • listen tap, close, leave, etc. event.

Docs

Please, read docs and try ANE before asking any questions.
https://developers.google.com/mobile-ads-sdk/
http://help.adobe.com/en_US/air/extensions/index.html

Installation

Extension ID: com.pozirk.ads.AdMob
Add "AdMob.ane" and "air\AdMob\bin\AdMob.swc" to your AIR project.
Add the following lines to your AIR Aplication-app.xml file inside <manifestAdditions> section:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
<meta-data android:name="com.google.android.gms.version" android:value="11020000" /> <!-- should be android:value="@integer/google_play_services_version" --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>

Example

import com.pozirk.ads.admob.AdMob;
import com.pozirk.ads.admob.AdParams;
import com.pozirk.ads.admob.AdEvent;

...

protected var _admob:AdMob = new AdMob();

...

//> initialization of AdMob
_admob.addEventListener(AdEvent.INIT_OK, onEvent);
_admob.addEventListener(AdEvent.INIT_FAIL, onEvent);
_admob.addEventListener(AdEvent.BANNER_SHOW_OK, onEvent);
_admob.addEventListener(AdEvent.BANNER_SHOW_FAIL, onEvent);
_admob.addEventListener(AdEvent.BANNER_LEFT_APP, onEvent);
_admob.addEventListener(AdEvent.BANNER_OPENED, onEvent);
_admob.addEventListener(AdEvent.BANNER_CLOSED, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_OK, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_FAIL, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_OK, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_FAIL, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_LEFT_APP, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_OPENED, onEvent);
_admob.addEventListener(AdEvent.INTERSTITIAL_CLOSED, onEvent);
_admob.init();

...

protected function onEvent(ae:AdEvent):void
{
	trace(ae.type+" "+ae._data);
}
//<


//showing smart-size ad at the bottom center side of the screen
_admob.show("AD_UNIT_ID", AdParams.SIZE_SMART_BANNER, AdParams.HALIGN_CENTER, AdParams.VALIGN_BOTTOM);

//hiding ad
_admob.hide();

//caching interstitial ad
_admob.cacheInterstitial("AD_UNIT_ID");
...
//showing interstitial ad, make sure it's cached first
_admob.showInterstitial();
...
//setting volume of the interstitial ad, can have sound, if it's video
_admob.setVolume(vol); //0-1 range, where 0 - mute, 1 - max volume (default, I guess).

Games with AdMob

https://play.google.com/store/apps/details?id=air.com.pozirk.allinonesolitaire
https://play.google.com/store/apps/details?id=air.com.pozirk.allinonemahjong
https://play.google.com/store/apps/details?id=air.com.pozirk.allinonemahjong2
https://play.google.com/store/apps/details?id=air.com.pozirk.allinonemahjong3
In order to see the interstitial ad, you need to win/lose any game.