Hi, I’ve a problem with Corona ads, I publish my app in play store and then I add the app in Corona ads.
My app in Corona ads has “Active” status but when I put the code in the documentation in my app doesn’t work.
I don’t have any error, my app works well but advertisements don’t be shown.
This is the piece of code that I use for ads.
What can I do?
build.setting
settings =
{
orientation =
{
– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight
default = “landscape”,
supported = { “landscape”, },
},
excludeFiles =
{
– Include only the necessary icon files on each platform
android = { “Icon.png”, },
},
–
– Android Section
–
android =
{
usesPermissions =
{
“android.permission.INTERNET”,
“android.permission.ACCESS_COARSE_LOCATION”,
“android.permission.ACCESS_FINE_LOCATION”,
“android.permission.ACCESS_NETWORK_STATE”
},
},
–
--Plugin Section
–
plugins =
{
[“plugin.google.play.services”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“shared.android.support.v4”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“plugin.coronaAds”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“plugin.chartboost”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“plugin.adcolony”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
}
}
}
Page when I want the advertisement:
–Play
–When player click play in main menu this class implements every levels present in the game
local composer = require( “composer” )
local scene = composer.newScene()
local sceneGroup
–Things for Advertisement
local coronaAds = require( “plugin.coronaAds” )
local chartboost = require( “plugin.chartboost” )
– Substitute your own placement IDs when generated
local bannerPlacement = “bottom-banner-320x50”
local interstitialPlacement = “prova”
function prepareAd()
– Initialize Corona Ads (substitute your own API key when generated)
coronaAds.init( “a**********************31”, adListener )
– Initialize the Chartboost plugin with your Corona Ads API key
chartboost.init( cbListener, { apiKey=“a*****************************31”, appOrientation=“landscape” } )
end
local function adListener( event )
– Successful initialization of Corona Ads
if ( event.phase == “init” ) then
– Show an ad
--coronaAds.show( bannerPlacement, false )
coronaAds.show( interstitialPlacement, true )
end
end
–
– Chartboost
– Chartboost listener function
local function cbListener( event )
if ( event.phase == “init” ) then – Successful initialization
chartboost.load( “interstitial” )
elseif ( event.phase == “loaded” ) then
if ( event.type == “interstitial” ) then
chartboost.show( “interstitial” )
end
end
end
– create()
function scene:create( event )
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Code here runs when the scene is still off screen (but is about to come on screen)
elseif ( phase == “did” ) then
– Code here runs when the scene is entirely on screen
prepareAd()
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Code here runs when the scene is on screen (but is about to go off screen)
elseif ( phase == “did” ) then
– Code here runs immediately after the scene goes entirely off screen
end
end
function scene:destroy( event )
local sceneGroup = self.view
– Code here runs prior to the removal of scene’s view
end
– Scene event function listeners
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene