Admob Difficulties + Tutorials?

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:

appId (required)

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  :frowning:

Can someone help me with my code and give me a link to a tutorial?

Thanks.

Hi @cozymonster29,

I believe we’re planning a tutorial on AdMob within the next week or so (hopefully next week), primarily because many users are confused about the “V1” versus the newer “V2” version of this, and the various subtle changes which come along with it. That should help straighten out the setup and practicalities of AdMob for you.

Best regards,

Brent

The appID is the ad Unit ID. It should be something like ca-app-pub-################/##########. This is the addID called in both

ads.init( provider, appID, adListener )

and

ads.show( adType, { x=adX, y=adY, appId = appID} )

Here is said tutorial:  http://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/

If you are using composer, you probably should still initialize your ads in your main.lua (where the adListener function would live) and then just call ads.show() when needed in your composer scenes.

Rob

Hi @cozymonster29,

I believe we’re planning a tutorial on AdMob within the next week or so (hopefully next week), primarily because many users are confused about the “V1” versus the newer “V2” version of this, and the various subtle changes which come along with it. That should help straighten out the setup and practicalities of AdMob for you.

Best regards,

Brent

The appID is the ad Unit ID. It should be something like ca-app-pub-################/##########. This is the addID called in both

ads.init( provider, appID, adListener )

and

ads.show( adType, { x=adX, y=adY, appId = appID} )

Here is said tutorial:  http://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/

If you are using composer, you probably should still initialize your ads in your main.lua (where the adListener function would live) and then just call ads.show() when needed in your composer scenes.

Rob