I followed https://github.com/lilili87222/admob-for-flash
I am still unable to see advertisements with admob ane.
Steps:
1.Init Admob ANE
Add Admob ane to air project build path, and add the following 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 an 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 which size banner to show
3.Remove Banner By default, banners are visible. To hide a banner,
Admob.getInstance().hideBanner();
4.Admob ANE Show Interstitial
Here is the minimal code to integrate an interstitial into an Air ios app or flex android app.
Admob.getInstance().cacheInterstitial("your Interstitial ID ");
Check that the interstitial is loaded 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
If you want advertisements to target children:
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 many ad events that you can register for. To set ad events on an interstitial and show interstitial when the ad is successfully loaded:
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();
}
}
8.Admob Rewarded Video
Video api is similar with Interstitial
To set an ad event on a video and show video when the ad is successfully loaded:
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");
}
}
9.IOS min version config
admob requires ios 8 and later
<key>MinimumOSVersion</key>
<string>8.0</string>
simple example
<iPhone>
<InfoAdditions><![CDATA[
<key>UIDeviceFamily</key>
<array>
<string>1</string>
<string>2</string>
</array>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
]]></InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
10.android permission config
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
<android>
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application>
<meta-data android:name="com.google.android.gms.version"
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" android:theme="@android:style/Theme.Translucent"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
</manifest>
]]></manifestAdditions>
</android>