Admob ANE is supported on Android and iOS with 100% identical ActionScript API with a super easy interface so you can focus on your game logic while your app is earning more for you the smart way!
Main Features:
- Supporting Banner and Interstitial Ads
- Having control over all required EventListeners
- Being able to position the Ads by pixels
- Optimized for AIR 24 and Firebase ANEs
find the latest asdoc for this ANE here.
How to get started? read here
NOTICE: the demo ANE works only after you hit the "OK" button in the dialog which opens. in your tests make sure that you are NOT calling other ANE methods prior to hitting the "OK" button. Download the ANE
import com.myflashlab.air.extensions.admob.AdMob;
import com.myflashlab.air.extensions.admob.AdRequest;
import com.myflashlab.air.extensions.admob.banner.ApiBannerAds;
import com.myflashlab.air.extensions.admob.events.AdMobEvents;
import com.myflashlab.air.extensions.admob.events.BannerEvents;
// initialize AdMob and pass in the Adobe AIR Stage and your AdmMob ApplicationCode
AdMob.init(stage, "ca-app-pub-9002001127208746~3709582175");
// Add general listeners for the Ads
AdMob.api.addEventListener(AdMobEvents.AD_CLOSED, onAdClosed);
AdMob.api.addEventListener(AdMobEvents.AD_FAILED, onAdFailed);
AdMob.api.addEventListener(AdMobEvents.AD_LEFT_APP, onAdLeftApp);
AdMob.api.addEventListener(AdMobEvents.AD_LOADED, onAdLoaded);
AdMob.api.addEventListener(AdMobEvents.AD_OPENED, onAdOpened);
// listen to the banner Ad to get its final width/height in pixels
AdMob.api.banner.addEventListener(BannerEvents.SIZE_MEASURED, onBannerAdSizeReceived);
// to create a banner Ad, first you need to initialize a new banner with your unitId and prefered banner size
AdMob.api.banner.init("ca-app-pub-930840122057342/5256142323", ApiBannerAds.BANNER);
// then you should create a new Ad request
var adRequest:AdRequest = new AdRequest();
/*
You may customize your Ad requests in many different ways. Read here to learn more about Ad Requests
http://myflashlab.github.io/asdoc/com/myflashlab/air/extensions/admob/AdRequest.html
Yet, one of the handy options is the adRequest.testDevices property which allows you to pass an Array of all
your test devices so you can safely test your Ads before going live. If you don't know how you can receive your
device's ID, read here for Android:
https://firebase.google.com/docs/admob/android/targeting#test_ads
or here for iOS:
https://firebase.google.com/docs/admob/ios/targeting#test_ads
For the best practice usage of banner Ads, read here:
https://support.google.com/admob/answer/6128877?hl=en
*/
// Now that you have the Ad request ready, simply load your banner! That simple.
AdMob.api.banner.loadAd(adRequest);
// If you wish to change the position of the loaded banner, which is (0, 0) by default, you should listen for AdMobEvents.AD_LOADED
private function onAdLoaded(e:AdMobEvents):void
{
if (e.adType == AdMob.AD_TYPE_BANNER)
{
// place the Ad at the center of your game, or anywhere else you wish!
AdMob.api.banner.x = stage.stageWidth / 2 - AdMob.api.banner.width / 2;
AdMob.api.banner.y = stage.stageHeight / 2 - AdMob.api.banner.height / 2;
}
} import com.myflashlab.air.extensions.admob.AdMob;
import com.myflashlab.air.extensions.admob.AdRequest;
import com.myflashlab.air.extensions.admob.events.AdMobEvents;
// initialize AdMob and pass in the Adobe AIR Stage and your AdmMob ApplicationCode
AdMob.init(stage, "ca-app-pub-9002001127208746~3709582175");
// Add general listeners for the Ads
AdMob.api.addEventListener(AdMobEvents.AD_CLOSED, onAdClosed);
AdMob.api.addEventListener(AdMobEvents.AD_FAILED, onAdFailed);
AdMob.api.addEventListener(AdMobEvents.AD_LEFT_APP, onAdLeftApp);
AdMob.api.addEventListener(AdMobEvents.AD_LOADED, onAdLoaded);
AdMob.api.addEventListener(AdMobEvents.AD_OPENED, onAdOpened);
/*
One thing you should remember about interstitial Ads, is that you should load them first,
wait for them to be loaded, then show them when appropriate. For the best practice usage of
interstitial Ads, read here: https://support.google.com/admob/answer/6066980?hl=en
*/
// The first step is to initialize a new interstitial Ad with your unitId that you have created in your Admob console.
AdMob.api.interstitial.init("ca-app-pub-9476398060240162/1457820116");
// then create a new Ad request just like how you did for the Banner Ads
var adRequest:AdRequest = new AdRequest();
// And then load it!
AdMob.api.interstitial.loadAd(adRequest);
// now, you must wait for the banner to load before you can show it.
private function onAdLoaded(e:AdMobEvents):void
{
if (e.adType == AdMob.AD_TYPE_INTERSTITIAL)
{
// Your Ad is ready to be shown. show it whenever you like!
if(AdMob.api.interstitial.isLoaded)
{
AdMob.api.interstitial.show();
}
}
}<!--
FOR ANDROID:
-->
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!--The new Permission thing on Android works ONLY if you are targetting Android SDK 23 or higher-->
<uses-sdk android:targetSdkVersion="23"/>
<application>
<activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Include the AdActivity configChanges and themes. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
<!--
FOR iOS:
-->
<InfoAdditions>
<!--iOS 8.0 or higher can support this ANE-->
<key>MinimumOSVersion</key>
<string>8.0</string>
<!-- Required for iOS 9 support, read more about this here: https://firebase.google.com/docs/admob/ios/ios9 -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</InfoAdditions>
<!--
Embedding the ANE:
-->
<extensions>
<!-- download the dependency ANEs from https://github.com/myflashlab/common-dependencies-ANE -->
<extensionID>com.myflashlab.air.extensions.dependency.androidSupport</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.overrideAir</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.ads.lite</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.basement</extensionID>
<!-- And finally embed the main Admob ANE -->
<extensionID>com.myflashlab.air.extensions.admob</extensionID>
</extensions>
-->- Android API 15 or higher
- iOS SDK 8.0 or higher
- AIR SDK 22 or higher
- This ANE is dependent on androidSupport.ane, overrideAir.ane, googlePlayServices_adsLite.ane and googlePlayServices_basement.ane You need to add these ANEs to your project too. Download them from here:
- To compile on iOS, you will need to add the GoogleMobileAds framework to your AIR SDK.
- download Firebase iOS SDK and extract it on your computer.
- go to AdMob folder and find GoogleMobileAds.framework. just copy it as it is and go to your AdobeAir SDK.
- when in your AIR SDK, go to "\lib\aot\stub". here you will find all the iOS frameworks provided by AIR SDK by default.
- paste the frameworks you had copied into this folder and you are ready to build your project.
http://www.myflashlabs.com/product/firebase-admob-air-native-extension/
How to embed ANEs into FlashBuilder, FlashCC and FlashDevelop
How to get started with Admob?
Nov 29, 2016 - V2.0.0
- Min iOS version to support this ANE will be iOS 8.0+ from now on
- Updated iOS Admob SDK to V7.15.1 which is now a part of Firebase SDK V3.10.0
- To Add
GoogleMobileAds.frameworkto your AIR SDK, you need to download Firebase SDK V10.0.0 extract it, then go to folder AdMob and copy GoogleMobileAds.framework toYOUR_AIR_SDK/lib/aot/stub/folder. - Updated Android Admob SDK to Google Play Services dependencies V10.0.0 All you have to do is to download the latest dependency files as follow:
- androidSupport.ane V24.2.1
- overrideAir.ane V3.0.0
- googlePlayServices_adsLite.ane V10.0.0
- googlePlayServices_basement.ane V10.0.0
Nov 11, 2016 - V1.1.0
- Optimized for Android manual permissions if you are targeting AIR SDK 24+
- The following two dependencies need to be added to other ones also: androidSupport.ane and overrideAir.ane
Jun 07, 2016 - V1.0.1
- fixed a bug mentioned here: https://github.com/myflashlab/Admob-ANE/issues/2
Jun 05, 2016 - V1.0.0
- beginning of the journey!
