Hey Guys,
I am using Admob for the first time and I don’t
know whether my code for banner ads and for interstitial ads is correct.
There is the problem that there aren’t any ads if I test my app on a device.
This is the build settings code:
settings =
{
orientation =
{
default =“portrait”,
supported = {“portrait”},
},
plugins =
{
[“plugin.admob”] =
{
publisherId = “com.coronalabs”,
},
},
android =
{
midSdkVersion = "16",
applicationChildElements =
{
[[
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value=“ca-app-pub-3625432895557434~6682668397”/>
]],
},
},
{
versionCode = "16",
},
}
This is my main.lua code:
local admob = require( “plugin.admob” )
– AdMob listener function
local function adListener( event )
if ( event.phase == "init" ) then -- Successful initialization
-- Load an AdMob interstitial ad
admob.load( "interstitial", { adUnitId="*****************************" } )
end
end
– Initialize the AdMob plugin
admob.init( adListener, { appId="*******************************" } )
if ( admob.isLoaded( “interstitial” ) ) then
admob.show( “interstitial” )
end
admob = require( “plugin.admob” )
– Declare variable for storing banner height; this may change if device is rotated
local bannerHeight
– AdMob listener function
function adListener( event )
if ( event.phase == "init" ) then -- Successful initialization
-- Load an AdMob banner ad
admob.load( "banner", { adUnitId="*****************************************" } )
elseif ( event.phase == "loaded" ) then
if ( event.type == "banner" ) then -- Banner ad is loaded
bannerHeight = admob.height() -- Get the loaded banner's height
-- Show the banner ad with a 30 pixel gap between the screen bottom
admob.show( "banner", { y = display.actualContentHeight - bannerHeight - 30 } )
end
end
end
– Initialize the AdMob plugin
admob.init( adListener, { appId="******************************" } )
Is there anybody who knows what an Application ID in the build settings is?
And what other thing do I need in my project folder?
Thank you for every help!!!