Inmobi for dummies

Hello everybody.

Im trying use inmobi plugin.
Already out the code as example in configuration file, also some code on main.lua as show on Corona docs.
Also tryed other codes from web.
None works, seems that cannot show at simulator (the documentations says it is not possible), but also nothing appears when build apk (not published in Google Store, only in my PC-Mobile).

In inmobi the name of app is ONLY for example “anuncio” or com.coimbras.anuncio?

Anyone show me a very Basic functional code? And what to fill at inmobi page? Only for a bottom banner…

Inmobi or monetize for dummies :grin:

Have you read this yet?

http://docs.coronalabs.com/tutorial/basics/ads/index.html

Rob

And please don’t just copy/paste the code and expect it to work.  The tutorial covers the “Why?” and “How?” for ads in general. Once you understand the advertising and how it works then you can adapt inmobi.

Rob 

Hello.

Yes already read.

Sorry but is not clear to me, besides is not a native language to me (portuguese) to have  full understood all… :frowning:

also checked AdMod, they provide test ids for programmers, in InMobi they dont provide it, so, theres is the doubt if is a problem/error of programming or som inserted date in their website.

Thanks anyway.

Here is one of the (many codes) i´m trying… something wrong, the adListener function do not produce any of the “prints” to the console (on simulator) or text in real device. Its like not running the function. 

PS: Already tryed to no put the inMobi.init() inside a function, and also without the timer :frowning:

Many thanks if someone can help me.

local widget = require( "widget" ) local inMobi = require("plugin.inMobi") local myText = display.newText( "Anuncio", 160, 20, native.systemFont, 16 ) myText:setFillColor( 1, 0, 0 ) local myText0 = display.newText( "Anuncio ------", 160, 290, native.systemFont, 16 ) local myText1 = display.newText( "loaded", 160, 300, native.systemFont, 16 ) local myText2 = display.newText( "loaded placement id", 160, 310, native.systemFont, 16 ) local myText3 = display.newText( "loaded type ", 160, 320, native.systemFont, 16 ) local myText4 = display.newText( "failed placement id ", 160, 330, native.systemFont, 16 ) local myText5 = display.newText( "failed error ", 160, 340, native.systemFont, 16 ) local myText6 = display.newText( "failed response ", 160, 350, native.systemFont, 16 ) local myText7 = display.newText( "inmobi is loaded ", 160, 360, native.systemFont, 16 ) local function adListener( event ) if ( event.phase == "init" ) then --successful initialize -- load a banner ad inMobi.load( "Banner", "1553678101219" ) myText0.text="init " elseif ( event.phase == "loaded" ) then --the ad was loaded print( event.type ) myText1.text="Loaded "..event.type print( event.placementId ) myText2.text="Placement id"..event.placementId elseif ( event.phase == "failed" ) then --the ad failed to load print( event.type ) myText3.text="Failed id"..event.type print( event. placementId ) myText4.text="Failed placement id "..event.placementId print( event.isError ) myText5.text="Failed error "..event.isError print( event.response ) myText6.text="Failed response "..event.response end myText0.text="Anuncio - Funcao adListener " end function iniciaInMobi() --initialize the inmobi plugin inMobi.init( adListener, { accountId="7eb029026f4a4659b45306264a59f104", logLevel="debug", hasUserConsent=true } ) --sometime later check if the ad is loaded myText.text="Anuncio - Funcao iniciaInMobi" end function mostraInMobi() if ( inMobi.isLoaded( "1553678101219" ) ) then --show the ad myText7.text="InMobi is Loaded! " inMobi.show ( "1553678101219", { yAlign="bottom" } ) else myText7.text="InMobi is NOT Loaded! " end myText.text="Anuncio - Funcao mostraInMobi" end function timerbanner() timer.performWithDelay( 1000, iniciaInMobi ) end button1=display.newRect(display.contentCenterX, display.contentHeight\*.20,display.contentWidth\*.70,display.contentHeight\*.06) button1:setFillColor(1,1,0) button2=display.newRect(display.contentCenterX, display.contentHeight\*.30,display.contentWidth\*.7,display.contentHeight\*.06) button2:setFillColor(1,1,0) button1:addEventListener("tap", timerbanner) button2:addEventListener("tap", mostraInMobi)

I would do this:

local json = require("json") local function adListener( event )     print(json.prettify( event )     -- the rest of your code end

Then you can look at the console log and see if adListener is getting called and all the values being passed to it.

Rob

Hi. Thanks for reply.

An output of Json, says to me that everithing is ok…

  1. “name”.“adsRequest”,
  2. “phase”.“loaded”,
  3. “placementId”."1553678101219 " (was wrong before)
  4. “provider”.“inMobi”,
  5. “type”.“banner”,
  6. “isError”.“false”.

It seems that   “if ( inMobi.isLoaded( 1553678101219 ) ) then” produces a false sentence.

Already see that in the inMobi.isLoaded and inMobi.Show the placement ID is without quotes (all the other code is in quostes “” for ids.

Almost there but not …

Many thanks.

Seems to show the banner now, with this modification of the code… Its a BIG Advance, almost there :slight_smile:

It still have some erratic behaviour. Sometimes don´t work the app. When delete and reinstall works… 

Maybe should anyway be  reset to the ad?

Going on …

local widget = require( "widget" ) local inMobi = require("plugin.inMobi") local json = require("json") local myText = display.newText( "Anuncio", 160, 20, native.systemFont, 16 ) myText:setFillColor( 1, 0, 0 ) local myTextJson = display.newText( "Json", 160, 40, native.systemFont, 8 ) local myText0 = display.newText( "Anuncio ------", 160, 290, native.systemFont, 16 ) local myText1 = display.newText( "loaded", 160, 300, native.systemFont, 16 ) local myText2 = display.newText( "loaded placement id", 160, 310, native.systemFont, 16 ) local myText3 = display.newText( "loaded type ", 160, 320, native.systemFont, 16 ) local myText4 = display.newText( "failed placement id ", 160, 330, native.systemFont, 16 ) local myText5 = display.newText( "failed error ", 160, 340, native.systemFont, 16 ) local myText6 = display.newText( "failed response ", 160, 350, native.systemFont, 16 ) local myText7 = display.newText( "inmobi is loaded ", 160, 360, native.systemFont, 16 ) local function adListener( event ) print(json.prettify( event )) myTextJson.text="Jason - "..json.prettify( event ) if ( event.phase == "init" ) then --successful initialize -- load a banner ad inMobi.load( "Banner", "1554277121369" ) myText0.text="Init " elseif ( event.phase == "loaded" ) then --the ad was loaded print( event.type ) myText1.text="Loaded "..event.type print( event.placementId ) myText2.text="Placement id"..event.placementId elseif ( event.phase == "failed" ) then --the ad failed to load print( event.type ) myText3.text="Failed id"..event.type print( event. placementId ) myText4.text="Failed placement id "..event.placementId print( event.isError ) myText5.text="Failed error "..event.isError print( event.response ) myText6.text="Failed response "..event.response end --myText0.text="Anuncio - Funcao adListener " end function iniciaInMobi() --initialize the inmobi plugin inMobi.init( adListener, { accountId="7eb029026f4a4659b45306264a59f104", logLevel="debug", hasUserConsent=true } ) --sometime later check if the ad is loaded myText.text="Anuncio - Funcao iniciaInMobi" end function mostraInMobi() --[[if ( inMobi.isLoaded( 1554277121369 ) ) then --show the ad myText7.text="InMobi is Loaded! " inMobi.show ( 1554277121369, { yAlign="bottom" } ) else myText7.text="InMobi is NOT Loaded! " end myText.text="Anuncio - Funcao mostraInMobi"]]-- --Para efeios de teste coloquei aqui o show fora das condições inMobi.show ( "1554277121369", { yAlign="bottom" } ) end function timerbanner() timer.performWithDelay( 1000, iniciaInMobi ) end button1=display.newRect(display.contentCenterX, display.contentHeight\*.20,display.contentWidth\*.70,display.contentHeight\*.06) button1:setFillColor(1,1,0) button2=display.newRect(display.contentCenterX, display.contentHeight\*.30,display.contentWidth\*.7,display.contentHeight\*.06) button2:setFillColor(1,1,0) button1:addEventListener("tap", timerbanner) button2:addEventListener("tap", mostraInMobi)

This ID number isn’t really a number, it’s a string. When you specify it, you should put it inside quotes such as “1553678101219” not 1553678101219

Most ad vendors, once you call the .show() method, will rotate the banner ad on their schedule, or give you a parameter that lets you specify when it should reload the ad. You can always call the .hide() method to hide the ad and another .show() to reshow the ad.

It looks like you may need to initially call the .load() method after a successful information (this was discussed in the Implementing Ads tutorial). The .load() method is where you can determine if you want to use autorefresh and set the frequency (defaults to 60 seconds).  Make sure you’re calling .load() before you call .show()

Rob

Well, in “test mode”, works, when upload to google play, and insert the app URL in Inmobi portal, doesn´t work anymore.

Can anyone tell me if is some change in code? I was reading, it seems not. The only diference i see is in InMobi portal, if dons put an URL is a test mode, if put URL (and fill the new fields) is a production app.

Thanks.

Have you read this yet?

http://docs.coronalabs.com/tutorial/basics/ads/index.html

Rob

And please don’t just copy/paste the code and expect it to work.  The tutorial covers the “Why?” and “How?” for ads in general. Once you understand the advertising and how it works then you can adapt inmobi.

Rob 

Hello.

Yes already read.

Sorry but is not clear to me, besides is not a native language to me (portuguese) to have  full understood all… :frowning:

also checked AdMod, they provide test ids for programmers, in InMobi they dont provide it, so, theres is the doubt if is a problem/error of programming or som inserted date in their website.

Thanks anyway.

Here is one of the (many codes) i´m trying… something wrong, the adListener function do not produce any of the “prints” to the console (on simulator) or text in real device. Its like not running the function. 

PS: Already tryed to no put the inMobi.init() inside a function, and also without the timer :frowning:

Many thanks if someone can help me.

local widget = require( "widget" ) local inMobi = require("plugin.inMobi") local myText = display.newText( "Anuncio", 160, 20, native.systemFont, 16 ) myText:setFillColor( 1, 0, 0 ) local myText0 = display.newText( "Anuncio ------", 160, 290, native.systemFont, 16 ) local myText1 = display.newText( "loaded", 160, 300, native.systemFont, 16 ) local myText2 = display.newText( "loaded placement id", 160, 310, native.systemFont, 16 ) local myText3 = display.newText( "loaded type ", 160, 320, native.systemFont, 16 ) local myText4 = display.newText( "failed placement id ", 160, 330, native.systemFont, 16 ) local myText5 = display.newText( "failed error ", 160, 340, native.systemFont, 16 ) local myText6 = display.newText( "failed response ", 160, 350, native.systemFont, 16 ) local myText7 = display.newText( "inmobi is loaded ", 160, 360, native.systemFont, 16 ) local function adListener( event ) if ( event.phase == "init" ) then --successful initialize -- load a banner ad inMobi.load( "Banner", "1553678101219" ) myText0.text="init " elseif ( event.phase == "loaded" ) then --the ad was loaded print( event.type ) myText1.text="Loaded "..event.type print( event.placementId ) myText2.text="Placement id"..event.placementId elseif ( event.phase == "failed" ) then --the ad failed to load print( event.type ) myText3.text="Failed id"..event.type print( event. placementId ) myText4.text="Failed placement id "..event.placementId print( event.isError ) myText5.text="Failed error "..event.isError print( event.response ) myText6.text="Failed response "..event.response end myText0.text="Anuncio - Funcao adListener " end function iniciaInMobi() --initialize the inmobi plugin inMobi.init( adListener, { accountId="7eb029026f4a4659b45306264a59f104", logLevel="debug", hasUserConsent=true } ) --sometime later check if the ad is loaded myText.text="Anuncio - Funcao iniciaInMobi" end function mostraInMobi() if ( inMobi.isLoaded( "1553678101219" ) ) then --show the ad myText7.text="InMobi is Loaded! " inMobi.show ( "1553678101219", { yAlign="bottom" } ) else myText7.text="InMobi is NOT Loaded! " end myText.text="Anuncio - Funcao mostraInMobi" end function timerbanner() timer.performWithDelay( 1000, iniciaInMobi ) end button1=display.newRect(display.contentCenterX, display.contentHeight\*.20,display.contentWidth\*.70,display.contentHeight\*.06) button1:setFillColor(1,1,0) button2=display.newRect(display.contentCenterX, display.contentHeight\*.30,display.contentWidth\*.7,display.contentHeight\*.06) button2:setFillColor(1,1,0) button1:addEventListener("tap", timerbanner) button2:addEventListener("tap", mostraInMobi)

I would do this:

local json = require("json") local function adListener( event )     print(json.prettify( event )     -- the rest of your code end

Then you can look at the console log and see if adListener is getting called and all the values being passed to it.

Rob

Hi. Thanks for reply.

An output of Json, says to me that everithing is ok…

  1. “name”.“adsRequest”,
  2. “phase”.“loaded”,
  3. “placementId”."1553678101219 " (was wrong before)
  4. “provider”.“inMobi”,
  5. “type”.“banner”,
  6. “isError”.“false”.

It seems that   “if ( inMobi.isLoaded( 1553678101219 ) ) then” produces a false sentence.

Already see that in the inMobi.isLoaded and inMobi.Show the placement ID is without quotes (all the other code is in quostes “” for ids.

Almost there but not …

Many thanks.

Seems to show the banner now, with this modification of the code… Its a BIG Advance, almost there :slight_smile:

It still have some erratic behaviour. Sometimes don´t work the app. When delete and reinstall works… 

Maybe should anyway be  reset to the ad?

Going on …

local widget = require( "widget" ) local inMobi = require("plugin.inMobi") local json = require("json") local myText = display.newText( "Anuncio", 160, 20, native.systemFont, 16 ) myText:setFillColor( 1, 0, 0 ) local myTextJson = display.newText( "Json", 160, 40, native.systemFont, 8 ) local myText0 = display.newText( "Anuncio ------", 160, 290, native.systemFont, 16 ) local myText1 = display.newText( "loaded", 160, 300, native.systemFont, 16 ) local myText2 = display.newText( "loaded placement id", 160, 310, native.systemFont, 16 ) local myText3 = display.newText( "loaded type ", 160, 320, native.systemFont, 16 ) local myText4 = display.newText( "failed placement id ", 160, 330, native.systemFont, 16 ) local myText5 = display.newText( "failed error ", 160, 340, native.systemFont, 16 ) local myText6 = display.newText( "failed response ", 160, 350, native.systemFont, 16 ) local myText7 = display.newText( "inmobi is loaded ", 160, 360, native.systemFont, 16 ) local function adListener( event ) print(json.prettify( event )) myTextJson.text="Jason - "..json.prettify( event ) if ( event.phase == "init" ) then --successful initialize -- load a banner ad inMobi.load( "Banner", "1554277121369" ) myText0.text="Init " elseif ( event.phase == "loaded" ) then --the ad was loaded print( event.type ) myText1.text="Loaded "..event.type print( event.placementId ) myText2.text="Placement id"..event.placementId elseif ( event.phase == "failed" ) then --the ad failed to load print( event.type ) myText3.text="Failed id"..event.type print( event. placementId ) myText4.text="Failed placement id "..event.placementId print( event.isError ) myText5.text="Failed error "..event.isError print( event.response ) myText6.text="Failed response "..event.response end --myText0.text="Anuncio - Funcao adListener " end function iniciaInMobi() --initialize the inmobi plugin inMobi.init( adListener, { accountId="7eb029026f4a4659b45306264a59f104", logLevel="debug", hasUserConsent=true } ) --sometime later check if the ad is loaded myText.text="Anuncio - Funcao iniciaInMobi" end function mostraInMobi() --[[if ( inMobi.isLoaded( 1554277121369 ) ) then --show the ad myText7.text="InMobi is Loaded! " inMobi.show ( 1554277121369, { yAlign="bottom" } ) else myText7.text="InMobi is NOT Loaded! " end myText.text="Anuncio - Funcao mostraInMobi"]]-- --Para efeios de teste coloquei aqui o show fora das condições inMobi.show ( "1554277121369", { yAlign="bottom" } ) end function timerbanner() timer.performWithDelay( 1000, iniciaInMobi ) end button1=display.newRect(display.contentCenterX, display.contentHeight\*.20,display.contentWidth\*.70,display.contentHeight\*.06) button1:setFillColor(1,1,0) button2=display.newRect(display.contentCenterX, display.contentHeight\*.30,display.contentWidth\*.7,display.contentHeight\*.06) button2:setFillColor(1,1,0) button1:addEventListener("tap", timerbanner) button2:addEventListener("tap", mostraInMobi)

This ID number isn’t really a number, it’s a string. When you specify it, you should put it inside quotes such as “1553678101219” not 1553678101219

Most ad vendors, once you call the .show() method, will rotate the banner ad on their schedule, or give you a parameter that lets you specify when it should reload the ad. You can always call the .hide() method to hide the ad and another .show() to reshow the ad.

It looks like you may need to initially call the .load() method after a successful information (this was discussed in the Implementing Ads tutorial). The .load() method is where you can determine if you want to use autorefresh and set the frequency (defaults to 60 seconds).  Make sure you’re calling .load() before you call .show()

Rob

Well, in “test mode”, works, when upload to google play, and insert the app URL in Inmobi portal, doesn´t work anymore.

Can anyone tell me if is some change in code? I was reading, it seems not. The only diference i see is in InMobi portal, if dons put an URL is a test mode, if put URL (and fill the new fields) is a production app.

Thanks.