How to show AdMob ads (iOs and Android) through Ac

2019-07-21 05:20发布

问题:

I am creating a flash game in Actionscript 3 and Flash CC. I intend to publish the game for iOs and Android.

I am looking for a way to show AdMob ads in Actionscript.

So far I have done those steps but no ads appear anywhere on screen:

  1. I have downloaded admob_all_in_one6.6.7.ane from here.
  2. I added the ane to my build path.
  3. I use the code below when the game is starting, before anything else:

    import so.cuo.platform.admob.Admob;
    import so.cuo.platform.admob.AdmobPosition;
    import so.cuo.platform.admob.AdmobEvent;
    import so.cuo.platform.admob.AdmobSize;
    
    var admob:Admob= Admob.getInstance();
    if(admob.supportDevice){
        admob.setKeys("9141023615", "6222882810");//changed my keys with random ones
        admob.addEventListener(AdmobEvent.onInterstitialReceive,onAdReceived);
        admob.addEventListener(AdmobEvent.onBannerReceive,onAdReceived);
        admob.cacheInterstitial();
        admob.enableTrace=true;
    }
    
    function onAdReceived(event:AdmobEvent):void
    {
        if(event.type==AdmobEvent.onBannerReceive){
            admob.showBanner(Admob.BANNER,AdmobPosition.TOP_CENTER);
        }
        if(event.type==AdmobEvent.onInterstitialReceive){
            admob.showInterstitial();
        }
    }
    

I have tried both banner and interstitial ads and none of them show up. I downloaded the app on my iPad and checked that it passes the if(admob.supportDevice) stage by showing a dynamic text field on screen.

My questions are:

  1. I am not quite sure what the "keys" are. So far I copied the part after / for each application (ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX).
  2. If what I did in 1. is correct, do you have any idea why no ads show up?

I have not used AdMob in any other language so I am not too experienced with it.

回答1:

I did have exactly the same problem with "so.cuo.platform.admob.Admob"

And i waste a lot of time to make it work.

When i manage to integrate it the app was refused since the library is obsolete.

I then found this other ANE extension which seems a lot more complete:
- https://github.com/lancelot1/ane-admob

This did work at first try also in Flash CC, and the app did pass the approval.

The ad in the app are now working flawless!

Strongly suggested if you still have issue, or if you wish to switch on a more advance extension.



回答2:

follow the doc https://code.google.com/p/flash-air-admob-ane-for-ios-and-android/

your Admob ID format is error,must be format

ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX

not part after /