Admob integration

The corona ads support said the only reason I’m not getting ads is because my app isn’t live. But I have another question about admob and the turtoial you made about how to integrate it.

 

 

In the ads.init line you had appID but in the code there is no variable appID but there is a variable interstitialAppID so is the ads.init line supposed to ads.init(adProvider, interstitialAppID, adListener)? 

Yes, you would substitute the right ID for what you’re trying to do.

Rob

local ads=require("ads") local AppID local interstitialAppID="ca-app-pub-2417127176280491/9212230961" if(system.getInfo("platformName")=="Android")  then interstitialAppID="ca-app-pub-2417127176280491/9212230961" end local adProvider="admob" local function adListenerr( event ) local msg=event.respone print("Message from the ads library: ", msg) if (event.isError) then print("Error buddy", msg) else ads.show("interstitial", {AppID=interstitialAppID}) print("Lets GOOO!") end end ads.init(adProvider,"ca-app-pub-2417127176280491/9212230961", adListenerr)

This is my code for my admob integration. I am trying to get an interstitial ad to show up. The name of my interstitial Ad unit is “TheMan300x250” , I did not include that in my code because I do not think the integration steps ask for the ad unit name. The ad unit id is already incorporated (it is not my actual id, changed it for privacy). For some reason my code is not working. Why is this?

Let’s see if I can simplify this:

local provider = "admob" bannerAappId = "ca-app-pub-5387163376908424/0123456789" interstitialAppId = "ca-app-pub-5387163376908424/9876543210" local function adListener( event ) -- event table includes: -- event.provider -- event.isError (e.g. true/false ) local msg = event.response -- just a quick debug message to check what response we got from the library print("Message received from the ads library: ", msg) end ads.init( provider, bannerAppId, adListener ) -- you could use interstitialAppId here too -- -- Then later on when you're ready to show an ad -- ads.show( "interstitial", { appId = interstitialAppId } ) -- show interstitial ad or ads.show( "banner", { appId = bannerAppId } ) -- show banner ad

Can I ask a question about Admob integration? This my code it works but I’m not sure this is right way for integration.My code is right or wrong? 

local ads = require( "ads" ) local appID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" local function adListener( event ) if ( event.isError ) then -- Failed to receive an ad statusText.Text = event.isError; end end ads.init( "admob", "xxxxxxxxxxxxxxxxxxxxxxxxxxx", adListener ) -- Optional table containing targeting parameters local targetingParams = { tagForChildDirectedTreatment = true } -- ads.show( "interstitial", { x=0, y=0, targetingOptions=targetingParams , appID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } )

In live 15, appID should be appId (lower case D on the end).

As long as the value of your appId is the right one for an interstitial ad on the platform you’re building for, and you’re calling ads.show() after enough time has elapsed that the .init() function is finished and you’re not getting errors for other things, it should work.

Rob

Thank yıu very much Rob:) It’s work :slight_smile:

Yes, you would substitute the right ID for what you’re trying to do.

Rob

local ads=require("ads") local AppID local interstitialAppID="ca-app-pub-2417127176280491/9212230961" if(system.getInfo("platformName")=="Android")  then interstitialAppID="ca-app-pub-2417127176280491/9212230961" end local adProvider="admob" local function adListenerr( event ) local msg=event.respone print("Message from the ads library: ", msg) if (event.isError) then print("Error buddy", msg) else ads.show("interstitial", {AppID=interstitialAppID}) print("Lets GOOO!") end end ads.init(adProvider,"ca-app-pub-2417127176280491/9212230961", adListenerr)

This is my code for my admob integration. I am trying to get an interstitial ad to show up. The name of my interstitial Ad unit is “TheMan300x250” , I did not include that in my code because I do not think the integration steps ask for the ad unit name. The ad unit id is already incorporated (it is not my actual id, changed it for privacy). For some reason my code is not working. Why is this?

Let’s see if I can simplify this:

local provider = "admob" bannerAappId = "ca-app-pub-5387163376908424/0123456789" interstitialAppId = "ca-app-pub-5387163376908424/9876543210" local function adListener( event ) -- event table includes: -- event.provider -- event.isError (e.g. true/false ) local msg = event.response -- just a quick debug message to check what response we got from the library print("Message received from the ads library: ", msg) end ads.init( provider, bannerAppId, adListener ) -- you could use interstitialAppId here too -- -- Then later on when you're ready to show an ad -- ads.show( "interstitial", { appId = interstitialAppId } ) -- show interstitial ad or ads.show( "banner", { appId = bannerAppId } ) -- show banner ad

Can I ask a question about Admob integration? This my code it works but I’m not sure this is right way for integration.My code is right or wrong? 

local ads = require( "ads" ) local appID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" local function adListener( event ) if ( event.isError ) then -- Failed to receive an ad statusText.Text = event.isError; end end ads.init( "admob", "xxxxxxxxxxxxxxxxxxxxxxxxxxx", adListener ) -- Optional table containing targeting parameters local targetingParams = { tagForChildDirectedTreatment = true } -- ads.show( "interstitial", { x=0, y=0, targetingOptions=targetingParams , appID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } )

In live 15, appID should be appId (lower case D on the end).

As long as the value of your appId is the right one for an interstitial ad on the platform you’re building for, and you’re calling ads.show() after enough time has elapsed that the .init() function is finished and you’re not getting errors for other things, it should work.

Rob

Thank yıu very much Rob:) It’s work :slight_smile: