Corona version: 3184
Admob plugin version: 1.2.2
Hello,
I am having a problem getting banner ads to display. The app will init the Admob plugin (set to testMode = true) and in the adListener monitor for event.phase == “init”. Once “init” has been detected, the code will then proceed to attempt to load an ad. This is where the mystery lies. Once admob attempts to load the ad,
event.phase is “failed”,
event.response is “loadFailed”
event.data is {“errorMsg”:“No Ads Available”,“errorCode”:3,“adUnitId”:“ca-app-pub-*****”}
[lua]
main.lua
local admob = require( “admob” )
. . .
admob.ads.init( admob.adListener, { appId = admob.AppID, testMode = true } )
admob.lua
local Z = {}
Z.ads = require( “plugin.admob” )
Z.bannerAdUnitID = “ca-app-pub-*****” – iOS by default
Z.interstitialAdUnitID = “ca-app-pub-*****” – iOS by default
Z.AppID = “ca-app-pub-*****” – iOS by default
if ( system.getInfo( “platformName” ) == “Android” ) then
– AdUnitID
Z.bannerAdUnitID = “ca-app-pub-*****”
Z.interstitialAdUnitID = “ca-app-pub-*****”
Z.AppID = “ca-app-pub-*****”
end
Z.adProvider = “admob”
– function displays a banner ad
local function showBanner()
Z.ads.show( “banner”, { y=“bottom” } )
end – end showBanner()
Z.showBanner = showBanner
local function adListener( event )
print(“Ad listener was called!”)
print("Phase: " … event.phase)
if (event.phase == “displayed” and event.type == “interstitial”) then
showBanner()
elseif(event.phase == “refreshed”) then
print(“Refresh ad”)
elseif(event.phase == “loaded”) then
print(“If Banner Ad is loaded, so show it!”)
print("Type: " … event.type)
– show the banner
if(event.type == “banner”) then
showBanner()
end
elseif(event.phase == “init”) then
print(“Now load the banner & interstitial”)
– load the banner here
Z.ads.load( “banner”, { adUnitId = Z.bannerAdUnitID } )
elseif( event.phase == “failed”) then
print(“Event failed…data to follow”)
print(event.response)
print(event.data)
elseif( event.iserror ) then
print(“We should try to get a different ad!”)
end
end
Z.adListener = adListener
– function hides the banner and shows an Interstitial
local function showInterstitial( testOrProd )
– hide the banner
Z.ads.hide()
Z.ads.show(“interstitial”)
end – end showInterstitial()
Z.showInterstitial = showInterstitial
return Z
[/lua]
I saw this post which is similar only he is in Malaysia (I am in US currently). Additionally there was this post where a Corona employee posted a link to a sample project. I tried the sample project and it does work with my credentials (meaning that it does load an ad with my appId and adUnitId) however that app is structured differently in that it does not load the ad automatically, only when you click the Load button. I sense there is something obvious that I am missing but can’t seem to connect with. Any suggestions are appreciated!
Thank you,
Ed