iAds

Ive been trying to put iAds into my game but I can’t seem to get it to work.  Ive looked over all the examples corona has put out and Ive tried them in my app.  But when I build it and put it on my phone it does nothing.  Can anyone help with this please.

Thanks!

Have you followed these guidelines?  http://docs.coronalabs.com/guide/monetization/adSupport/index.html

Make sure you enable it in iTunes Connect (look for the Manage iAd App Network button and follow the instructions).

I was able to implement a rotating banner on my app fairly easily.  Because Feather was my first free game, I wanted to make sure that it hit the ads correctly for proper monetization.  I wasn’t sure if iAds worked in all countries, and I know iAds don’t work on non-iOS devices, so this is my implementation (Flurry Analytics event logging also shown):

My build.settings file:

settings = { plugins = { ["CoronaProvider.ads.iads"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone = true }, }, ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs", }, } }

In my main.lua file:

\_G.platform = system.getInfo( "platformName" ) \_G.iAdsAppID = "com.company.product" \_G.adMobAppID = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" ... -- set up ads local ads = require "ads" local adRelated = {} adRelated.seconds = 0 adRelated.delay = 30 adRelated.hidden = true if \_G.platform == "iPhone OS" then -- try to show iAds first, AdMob as backup local function adListener2( event ) local msg = event.response if event.isError then analytics.logEvent( "Ads: Error with AdMob service" ) else analytics.logEvent( "Ads: Non-error response with AdMob service" ) end end local function adListener( event ) local msg = event.response if event.isError then analytics.logEvent( "Ads: Error with iAd service, falling back to AdMob" ) ads.init( "admob", \_G.adMobAppID, adListener2 ) else analytics.logEvent( "Ads: Non-error response with iAds service" ) end end analytics.logEvent( "Ads: Initializing iAds service" ) ads.init( "iads", \_G.iAdsAppID, adListener ) else -- show AdMob first, no backup ad service yet local function adListener( event ) local msg = event.response if event.isError then analytics.logEvent( "Ads: Error with AdMob service" ) else analytics.logEvent( "Ads: Non-error response with AdMob service" ) end end analytics.logEvent( "Ads: Initializing AdMob service" ) ads.init( "admob", \_G.adMobAppID, adListener ) end ... ads.show( "banner", { x = 0, y = 0 } )

Surprisingly, I seem to be getting more hits with Google’s AdMob than iAds on my iOS devices, so there may be some hiccups with the iAds service, but at least I’m getting one or the other.  You could also do something similar to incorporate all the ad companies.

I get this error when putting in the code:

Storyboard/main.lua:46: attempt to index global ‘analytics’ (a nil value)

line 46:     analytics.logEvent( “Ads: Initializing AdMob service” )

Remove those analytics.logEvent commands.  Those are for the Flurry Analytics plug-in I’m using.

Ok got it.  So when I build the app and put it on my device for testing it should show the ads right?

You should see the test banner from Apple, and when it goes live (when Apple approves both the iAd enabling in your app and the app itself), you’ll see real banners.

WOOHOO I SEE THE BANNER!!! Its at the top of the screen so i need to move it to the bottom, but its working!!! THANK YOU!!!

Glad to hear it!  If there’s a “resolved” or “solved” button on this forum thread, please click it so people know the issue has been resolved.  Thanks.

Will do when I find the button lol.  One more questions. When testing the app the iAds “testing” banner goes away after a little bit.  Is this normal?

Yes, I believe it’s part of the rotation.  If there’s no ad to fill at the moment, it doesn’t show anything (no need to force another ad.show method again, it will appear again).

Have you followed these guidelines?  http://docs.coronalabs.com/guide/monetization/adSupport/index.html

Make sure you enable it in iTunes Connect (look for the Manage iAd App Network button and follow the instructions).

I was able to implement a rotating banner on my app fairly easily.  Because Feather was my first free game, I wanted to make sure that it hit the ads correctly for proper monetization.  I wasn’t sure if iAds worked in all countries, and I know iAds don’t work on non-iOS devices, so this is my implementation (Flurry Analytics event logging also shown):

My build.settings file:

settings = { plugins = { ["CoronaProvider.ads.iads"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone = true }, }, ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs", }, } }

In my main.lua file:

\_G.platform = system.getInfo( "platformName" ) \_G.iAdsAppID = "com.company.product" \_G.adMobAppID = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" ... -- set up ads local ads = require "ads" local adRelated = {} adRelated.seconds = 0 adRelated.delay = 30 adRelated.hidden = true if \_G.platform == "iPhone OS" then -- try to show iAds first, AdMob as backup local function adListener2( event ) local msg = event.response if event.isError then analytics.logEvent( "Ads: Error with AdMob service" ) else analytics.logEvent( "Ads: Non-error response with AdMob service" ) end end local function adListener( event ) local msg = event.response if event.isError then analytics.logEvent( "Ads: Error with iAd service, falling back to AdMob" ) ads.init( "admob", \_G.adMobAppID, adListener2 ) else analytics.logEvent( "Ads: Non-error response with iAds service" ) end end analytics.logEvent( "Ads: Initializing iAds service" ) ads.init( "iads", \_G.iAdsAppID, adListener ) else -- show AdMob first, no backup ad service yet local function adListener( event ) local msg = event.response if event.isError then analytics.logEvent( "Ads: Error with AdMob service" ) else analytics.logEvent( "Ads: Non-error response with AdMob service" ) end end analytics.logEvent( "Ads: Initializing AdMob service" ) ads.init( "admob", \_G.adMobAppID, adListener ) end ... ads.show( "banner", { x = 0, y = 0 } )

Surprisingly, I seem to be getting more hits with Google’s AdMob than iAds on my iOS devices, so there may be some hiccups with the iAds service, but at least I’m getting one or the other.  You could also do something similar to incorporate all the ad companies.

I get this error when putting in the code:

Storyboard/main.lua:46: attempt to index global ‘analytics’ (a nil value)

line 46:     analytics.logEvent( “Ads: Initializing AdMob service” )

Remove those analytics.logEvent commands.  Those are for the Flurry Analytics plug-in I’m using.

Ok got it.  So when I build the app and put it on my device for testing it should show the ads right?

You should see the test banner from Apple, and when it goes live (when Apple approves both the iAd enabling in your app and the app itself), you’ll see real banners.

WOOHOO I SEE THE BANNER!!! Its at the top of the screen so i need to move it to the bottom, but its working!!! THANK YOU!!!

Glad to hear it!  If there’s a “resolved” or “solved” button on this forum thread, please click it so people know the issue has been resolved.  Thanks.

Will do when I find the button lol.  One more questions. When testing the app the iAds “testing” banner goes away after a little bit.  Is this normal?

Yes, I believe it’s part of the rotation.  If there’s no ad to fill at the moment, it doesn’t show anything (no need to force another ad.show method again, it will appear again).