IAds Working Code Sample

Sorry, it posted multiple times.

In iAdsAddOn.m with this function:

static int showAdFromTop(struct lua_State *state)
    NSLog(@"Show Ad From Top");
    [iAdsAddOnInstance setAdsAllowed: YES];
    [iAdsAddOnInstance setShowBannerFromTop: YES];
    [iAdsAddOnInstance showBannerViewAnimated: YES];
    return 0;

do you have the NSLog? If not, add it. Then see if the console prints ‘Show Ad From Top’

Nope. Here is my Main File:

 -- Faller
-- Use this function to perform your initial setup
 function setup()
  print("Hello World!")

 -- This function gets called once every frame
 function draw()
 -- This sets a dark background color 
 background(40, 40, 50)

 -- Do your drawing here


The debugger is open though.

Nothing is showing even though I just added the NSLog

It is almost if the function isn’t being called.

It works when I use this code though:

        NSLog(@"Ads should not be shown right now");
        [self hideBannerViewAnimated: NO];
        [iAdsAddOnInstance setAdsAllowed: YES];
        [iAdsAddOnInstance setShowBannerFromTop: YES];
        [iAdsAddOnInstance showBannerViewAnimated: YES];


I have to go now, but it will work fine for what i need using the code above. Thanks for all of your help!

@austinmccoy, adding that code just makes it so hideAd won’t work properly - I wouldn’t do that. Your problem seems to be that you are calling showAdFromTop before it is initialized which is odd. Is there any chance I could see your whole Xcode project?

Gladly, i will upload it to dropbox!

Here is my whole folder…


Immediately Xcode asked me to update the project settings. After that, the ad showed just as it should.

Really? I’ll try that.

i would like to test in the ios simulator on my mac if i have implemented iads correctly.
do i have to already declare the app in itunes connect?

played around a bit more, so now i can answer my own question!..it seems the simulator automatically generates an ad advertising iads without having to do anything at the itunes connect level.