Hi,
I’m trying to display a banner ad with AdMob. This is my code for the ad which I placed inside if ( phase == “will” ) then (since I’m using composer):
--Ads local ads = require "ads" --Corona's ads library local function adListener(event) print("event.isError = " .. tostring(event.isError)) end ads.init( "admob", "myAppId", adListener ) --Initialize the ads -- if on simulator, let user know they must build for device if system.getInfo("environment") == "simulator" then print( "Please build for device or Xcode simulator to test this sample.") else -- start with banner ad ads.show( "banner", { x=0, y=0, interval = 50} ) --Show ads end
And this is my build.settings:
-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { orientation = { default = "portrait", content = "portrait", supported = { "portrait", } }, iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXXXXXXX", -- example scheme for facebook "coronasdkapp", -- example second scheme } } } --]] } }, --[[-- Android permissions androidPermissions = { "android.permission.INTERNET", },]]-- plugins = { ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs" }, }, android = { usesPermissions = { "android.permission.VIBRATE", "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", }, }, }
When I run this on the device, I get this:
(Click the image to view the larger version)
I don’t understand why this is happening, and mainly because I can’t find a tutorial on how to use AdMob with Corona. My code is a mashup between the sample code and the docs page. Where can I find a tutorial on using AdMob with Corona?
Also, another question - I signed up for AdMob because I assumed I needed an AdMob account (again, no tutorial to help). I created a new app for monetization (“Monetize new app”) and was asked to create an ad unit. So, I created an ad unit. In the AdMob Docs page, it says that the syntax for ads.init is:
ads.init( providerName, appId [, adListener])
The providerName is “admob”, and I created an adListener (see the code above). But I don’t get what the appId is. According to the docs, it is:
String. String containing the app ID.
But what is the app id? Is it literally the name of my app, or is it the ad unit ID that I created? Or is it something else? With no tutorial to help me, I have no idea
Can someone help me with my code and give me a link to a tutorial?
Thanks.