Admob Air Native Extention(Admob ANE) provides a way to integrate admob ads in Air ios and Air Android Game and app. You can use it for Air iOS and Android App with the same actionscript code,not need any change ,not need java or oc.You not need Admob ANE for ios and Admob ANE for android Separate version any more with this Ane.
The Google Mobile Ads SDK is the latest generation in Google mobile advertising featuring refined ad formats and streamlined APIs for access to mobile ad networks and advertising solutions. The SDK enables Air mobile app developers to maximize their monetization in native mobile apps.
1.Init Admob ANE
Add Admob ane to air project build path , add the follow code in the script file
import so.cuo.platform.admob.*;
Admob.getInstance().initAdmobSDK("your admob app ID");
2.Add Admob Banner in adobe Air App
Here is the minimal code needed to show admob banner.
Admob.getInstance().showBanner("your banner ID ",AdmobSize.BANNER_320x50,AdmobPosition.BOTTOM_CENTER);
The AdmobPosition class specifies where to place the banner. AdmobSize specifies witch size banner to show
3.Remove Banner
By default, banners are visible. To hide a banner,
Admob.getInstance().hideBanner();
4.Admob ANE Show Interstitial
How to integrate Interstitial into Air ios app or flex android app? Here is the minimal code to create an interstitial.
Admob.getInstance().cacheInterstitial("your Interstitial ID ");
interstitials need to be loaded before shown. show at an appropriate stopping point in your app, check that the interstitail is ready before showing it:
if (Admob.getInstance().isInterstitialReady()) {
Admob.getInstance().showInterstitial();
}
5.Custom Admob Banner Ad Sizes
In addition to constants on AdSize, you can also create a custom size:
//Create a 320x250 banner.
AdSize adSize = new AdSize(320, 250);
Admob.getInstance().showBannerAbsolute(adSize,0,30);
6.Set Admob Target Param
set Admob target param such as test Ads and children app If you want to test the ads or the your app with children target,you can set with admob ANE easy
extraParam=new ExtraParameter();
extraParam.testDeviceID="true";
extraParam.isChildApp=true;//if is tagForChildDirectedTreatment,set true
extraParam.isDesignedForFamilies=true;
extraParam.nonPersonalizedAds=true;//if want to load non Personalized ads set true
Admob.getInstance().showBanner("Your banner ID",AdmobSize.BANNER_320x50,AdmobPosition.BOTTOM_CENTER,80,extraParam);
7.Ad Events
Both Banner and Interstitial contain the many ad events that you can register for.
Here we'll demonstrate setting ad events on a interstitial,and show interstitial when load success:
Admob.getInstance().addEventListener(AdmobEvent.onInterstitialReceive, onAdEvent);
private function onAdEvent(event:AdmobEvent):void
{
if (event.type == AdmobEvent.onBannerReceive)
{
trace(event.instanceName,event.data.width, event.data.height);
}
if (event.type == AdmobEvent.onInterstitialReceive)
{
Admob.getInstance().showInterstitial();
}
}
9.Admob Rewarded Video
Video api is similar with Interstitial
Here we'll demonstrate setting ad events on a video,and show video when load success:
if(admob.isVideoReady()){
admob.showVideo();
}else{
admob.cacheVideo(videoID);
}
Admob.getInstance().addEventListener(AdmobEvent.onVideoReceive, onVideoEvent);
private function onVideoEvent(event:AdmobEvent):void
{
if (event.type == AdmobEvent.onVideoReceive)
{
trace("load video success,you can show video now");
}
}
MinimumOSVersion is required for ios ,admob reqired ios 8 and later
MinimumOSVersion
8.0
simple example
UIDeviceFamily
1
2
MinimumOSVersion
8.0
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSAllowsArbitraryLoadsForMedia
NSAllowsArbitraryLoadsInWebContent
]]>
high
Meta Config com.google.android.gms.ads.APPLICATION_ID is required from admob 17 Please replace ca-app-pub-3940256099942544~3347511713 with your admob ID
]]>
this will get screen size ,unit is dp
Admob.getInstance().getScreenSize()
so.cuo.platform.admob
1.update admob sdk
2.support banner id for each banner
3.improve fill rate of video
4. support ios 12 and air 32
more
This Admob ANE was published since Sep, 2012, and has been downloaded more than 100,000 times. Now it's the No. 1 monetization ANE plugin for Flash Air community,More people use, making the api more friendly,the plugin more stable.Thank you for feedback questions and provide advice, thank you for the support and donations.
Download https://github.com/lilili87222/admob-for-flash/archive/master.zip
admob http://apps.admob.com
version with google firebase analysis https://github.com/lilili87222/Google-Firebase-ANE
Apache 2.0 License