Welcome to inneractive

@crssmn,

This is what I have for the banner sizes:

[lua] if ( display.contentWidth > 480 ) then
banner_width = 766
banner_height = 66
else
banner_width = 320
banner_height = 53
end[/lua]

So far these seem to work properly on all of the devices I have tested.

Orly, can you confirm that those values are correct, or if they are wrong can you tell us what they should be? [import]uid: 16734 topic_id: 19981 reply_id: 79535[/import]

Based on my testing with the iPhone4 the banner is not that size, unless there is as I’m suggesting a confusion of the difference between points and pixels. [import]uid: 10903 topic_id: 19981 reply_id: 79536[/import]

Easy to fix by dividing the content width height by the contentScale x y and use those values to determine your banner sizes.

I’ll post a fix to my routine to handle this when I get home. [import]uid: 16734 topic_id: 19981 reply_id: 79544[/import]

Hey guys, sorry to be “hijacking” into your conversation, BUT I am seing you all speaking about [lua]{ testMode=true }[/lua] and honestly I`ve never seen this option! Still now, I looked into the Docs and it does not show up there! :\

SO my question is: What happens when not setting this option of the ads.show API? I mean, not declaring it at all! I think it should be false by default. Is that right?
Thank you.
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 19981 reply_id: 79562[/import]

Yeah I don’t think it’s in the docs, but I assume false is the default. [import]uid: 10903 topic_id: 19981 reply_id: 79570[/import]

@Rodrigo, (are you Brazilian BTW?)
open corona simulator, click on samples apps and then on inneractive under ads.
then open the main file in the editor.
you will see that they have the testMode parameter there.
but nowhere else.
I wonder if it needs to be set to true while in testing, not in app store yet. [import]uid: 32063 topic_id: 19981 reply_id: 79574[/import]

It doesn’t have to be set to true during testing. The ads display for me without setting it to true. [import]uid: 10903 topic_id: 19981 reply_id: 79584[/import]

Here you go:

[lua]---------------------------------------------------------------------------------------
– Inneractive wrapper class

– File name: cInneractive.lua

– Usage:
– inneractive = require(“cInneractive”)
– APP_ID = “MY_Inneractive_App_ID” – use your app id here
– inneractive.Init( APP_ID )
– inneractive.Show() – no parameters required, will call Hide in 5 seconds
– or:
– inneractive.Show{
– cnt_text=“You can skip in”,
– skip_time=10,
– skip_text=“Tap to skip Advertisments”
– }

– If you have called Show(), but need to explicitly close the ad, you can do this to
– clean everything up:

– inneractive.Hide()


module(…, package.seeall)

local ads = require “ads”

local isSimulator = system.getInfo( “environment” ) == “simulator”
local fontScaleX = display.contentWidth/1024
local fontScaleY = display.contentHeight/769
– Objects needed here for cleanup
local adInfo = {}

– Forward references
local adSkipListener, adSkipGobbler

– *******************************************************************************************
– Init()

– Initialize the Ad system
– Parameters:
– appId Your Inneractive app ID
– onAdDisplayed Event callback called when
– ad is displayed
– *******************************************************************************************
function Init( appId, onAdDisplayed )
if ( isSimulator ) then
adInfo.theAdShowCallback = onAdDisplayed
print( “ads.init() cannot be called in the simulator” )
else
adInfo.theAdShowCallback = nil – Use their callback via the ads system
ads.init( “inneractive”, appId, onAdDisplayed )
end
end

– *******************************************************************************************
– Hide()

– Removes the ad and all of the display objects we created for the ad.
– *******************************************************************************************
function Hide()
if ( isSimulator ) then
print( “ads.hide() cannot be called in the simulator” )
else
– Hide the ad
ads.hide()
end

if ( adInfo.timer ) then
timer.cancel( adInfo.timer )
adInfo.timer = nil
end

– Now cleanup our objects
if ( adInfo.text ) then
adInfo.text:removeEventListener( “tap”, adSkipListener )
adInfo.text:removeEventListener( “touch”, adSkipListener )
– We don’t really need to do this here since the group remove will handle it, but
– since we are already cleaning up the event listeners we might as well remove it.
adInfo.text:removeSelf()
adInfo.text = nil
end
if ( adInfo.backImage ) then
adInfo.backImage:removeEventListener( “tap”, adSkipGobbler )
adInfo.backImage:removeEventListener( “touch”, adSkipGobbler )
– We don’t really need to do this here since the group remove will handle it, but
– since we are already cleaning up the event listeners we might as well remove it.
adInfo.backImage:removeSelf()
adInfo.backImage = nil
end

if ( adInfo.group ) then
adInfo.group:removeSelf()
adInfo.group = nil
end
end

– local function to gobble all tap/touch events for the background
function adSkipGobbler( event )
return true
end

– local function to invoke hiding the ad
function adSkipListener( event )
if ( adInfo.skip_time == 0 ) then
timer.performWithDelay( 50, Hide, 1 )
end
return true
end

– *******************************************************************************************
– Show( params )

– Parameters:
– params.x [Optional] background x position (Default is 0)
– params.y [Optional] background y position (Default is 0)
– params.w [Optional] background width (Default is display.contentWidth)
– params.h [Optional] background height (Default is display.contentHeight)
– params.color [Optional] background color (Default is { 255,255,255,255 } )
– params.interval [Optional] interval to refresh ads (Default is 60)
– params.skip_text [Optional] Text to show user they can skip the ad (Default is “Tap to Skip”)
– params.skip_font [Optional] Font used for skip_text (Default is native.systemFont)
– params.skip_time [Optional] Time (in seconds) before the Skip is active (Default is 5)
– params.cnt_text [Optional] Text to show user during the countdown (Default is “Skip in”)

– NOTES:
– If params.skip_time is 0 then the skip_text will be used as is. However, if
– skip_time is > 0 then the seconds remaining will be appending to the cnt_text
– *******************************************************************************************
function Show( params )
– we have no required parameters so we need to handle passing in nothing
if ( params == nil ) then
params = {}
end

local back_x = params.x or 0
local back_y = params.y or 0
local back_w = params.w or display.contentWidth
local back_h = params.h or display.contentHeight
local ad_interval = params.interval or 60
local cnt_text = params.cnt_text or “Skip in”
local skip_text = params.skip_text or “Tap to Skip”
local skip_font = params.skip_font or native.systemFont
local skip_time = params.skip_time or 5
local back_color = { 255, 255, 255, 255 }
local banner_width, banner_height

if ( params.color ) then
for i=1,#params.color do
back_color[i] = params.color[i]
end
end

– our group to draw to
adInfo.group = display.newGroup()

– save off values we will need later
adInfo.cnt_text = cnt_text
adInfo.skip_text = skip_text
adInfo.skip_time = skip_time
adInfo.timer = nil

– These banner sizes are from Inneractive for the iPhone/iPad. If
– you have different devices you can add a check based on sysModel
if ( math.round( display.contentWidth/display.contentScaleX ) > 480 ) then
banner_width = math.round( 766*display.contentScaleX )
banner_height = math.round( 66*display.contentScaleY )
else
banner_width = 320
banner_height = 53
end

– Center the ad in the background rect
local ad_x = back_x + math.round( 0.5*( back_w - banner_width ) )
local ad_y = back_y + math.round( 0.5*( back_h - banner_height ) )

adInfo.backImage = display.newRect( back_x, back_y, back_w, back_h )
adInfo.backImage:setFillColor( back_color[1], back_color[2], back_color[3], back_color[4] )

adInfo.group:insert( adInfo.backImage )
adInfo.backImage:addEventListener( “tap”, adSkipGobbler )
adInfo.backImage:addEventListener( “touch”, adSkipGobbler )

if ( isSimulator ) then
– These will get cleaned up when the adInfo.group is cleaned up
local dummy_ad = display.newRoundedRect( 0, 0, banner_width, banner_height, 8 )
dummy_ad:setFillColor( 0, 0, 0 )
dummy_ad:setReferencePoint( display.TopLeftReferencePoint )
dummy_ad.x = ad_x
dummy_ad.y = ad_y
adInfo.group:insert( dummy_ad )

local dummy_text = display.newText( “Dummy Ad”, 0, 0, native.systemFont, math.round( 32*fontScaleY ) )
dummy_text:setTextColor( 255, 255, 255 )
dummy_text:setReferencePoint( display.CenterReferencePoint )
dummy_text.x = display.contentCenterX
dummy_text.y = display.contentCenterY
adInfo.group:insert( dummy_text )
end

local textToUse
if ( skip_time > 0 ) then
textToUse = string.format( “%s %d”, cnt_text, skip_time )
else
textToUse = skip_text
end

adInfo.text = display.newText( textToUse, 0, 0, skip_font, math.round( 32*fontScaleY ) )
adInfo.text:setTextColor( 0, 0, 0 )
adInfo.text:setReferencePoint( display.BottomCenterReferencePoint )
adInfo.text.x = display.contentCenterX
adInfo.text.y = display.contentHeight - 4
adInfo.text:addEventListener( “tap”, adSkipListener )
adInfo.text:addEventListener( “touch”, adSkipListener )

adInfo.group:insert( adInfo.text )

if ( isSimulator ) then
print( “ads.show() not supported in the simulator” )
if ( theAdShowCallback ) then
– Since we aren’t using the actual ad system,
– so fake it with a callback
theAdShowCallback()
end
else
ads.show( “banner”, { x=ad_x, y=ad_y, interval=ad_interval } )
end

local function updateText( event )
adInfo.skip_time = adInfo.skip_time - 1
if ( adInfo.skip_time > 0 ) then
adInfo.text.text = string.format( “%s %d”, adInfo.cnt_text, adInfo.skip_time )
else
adInfo.text.text = adInfo.skip_text
end
end

if ( skip_time > 0 ) then
– Since we are using skip_time in seconds, that means we can use
– skip_time for the number of times to perform this timer event
adInfo.timer = timer.performWithDelay( 1000, updateText, skip_time )
end
end[/lua] [import]uid: 16734 topic_id: 19981 reply_id: 79092[/import]

@crssmn,

I’ve fixed my routine to properly handle iPhone 4 when you have display content sizes that are not equal to 960x640. This happens if you have your config.lua set to something like this:

[lua] content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 30,
antialias = true,

imageSuffix =
{
["@2x"] = 2,
}
}[/lua]

Since the above would result in display.contentWidth equal to 480 (for landscape mode).

The only changes where in lines 166 to 170.

If your app is running in portrait mode you may have some issues as I really haven’t tested that since all of our apps are running in landscape mode. [import]uid: 16734 topic_id: 19981 reply_id: 79589[/import]

Luciane , Yes, am Brazilian. By your name I believe you`re one too, right? :slight_smile:

So, thank you for the info, BUT my “problem” was exactly it. I mean, I am using the latest stable version of Corona right now because I was (until yesterday) in proccess of finalizing my code and app in total to be able to send it for Apple. And so I did! :slight_smile: But the problem was cause the latest stable version of Corona does not have this very same sample code under Inneractive`s example understand? In my version of Corona I do have innearctive sample without state anything about this flags (testMode True or False) into their code and so I did not know that it exist! :\

So I`ve sent my app for Apple still yesterday without set anything about it in my code. Like this I was afraid now when I see you guys speaking about it, because imagine it was like “obligatory” to be set, would be terrible right now for me.

PS: If you`re really Brazilian, sorry to be speaking in English as I could do much better in Portuguese (lol), BUT by respect for the other members here that do not speak Portuguese, I did “try” to write in English. :slight_smile:
Um abraço,
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 19981 reply_id: 79590[/import]

crssmn , I think like you. But what mm afraid of it all is that: If set testMode = true (inneractive does not “count” or monetize our ads - because they are under testMode set to true), and the other side as well as testMode = false (inneractive start to see it as a real live app and so start all the analytics and monetizing).

Does it make sense?

PS: I do not know if am very crazy thinking it I said above, BUT better to ask, speak, argue, etc than being one ignorant! lol

Edit: AND if I do make sense, I hope that the latest stable version of Corona as I was using to build my latest app (and as it wasn`t docummented as well) does not need this “testMode” option to be declared.
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 19981 reply_id: 79591[/import]

Oi Rodrigo, sim eu sou brasileira tambem! legal!
Poderias me mandar exemplo do teu code onde usaste ads, eu ainda nao consegui ver os ads no meu iPad.
Back to English…
I must be doing something wrong because we still can’t see any ads when we build for iPad and do adHoc disti, even setting testMode = true.
thanks, Luciane [import]uid: 32063 topic_id: 19981 reply_id: 79606[/import]

Hi crssmn, can you post example that works?
I still can’t see any ads. There must be something missing in my code. [import]uid: 32063 topic_id: 19981 reply_id: 79610[/import]

@Luciane , segue exatamente o código que utilizei abaixo. Só fiz retirar claro, meu AppID. Outra coisa que você pode estranhar é o fato dos valores para X e Y que utilizei, mas honestamente, DEPOIS DE MUITO TESTE, aí eu cheguei e me serviu para mostar o banner de Ads na parte de baixo do display (que é onde eu queria). Para você mudar isso, basta ir por tentativa e erro também. Sim, toda hora tem que fazer o build para o device porque Ads não mostra no simulador, enfim, foi um saco, mas tá feito. :slight_smile:

Espero que ajude.

Rodrigo.

(English)

The code Ive done to get it working is following bellow. I just have replaced my own AppID. Other thing that you may think "strange" is that to show the ads banner at the bottom of the display (as I wanted in my project) Ive “played” so much with those X and Y values and so youll see those values Ive got a little “hijacked”. :slight_smile: But all of this is try and error, nothing else btw.
Hope it helps.

Cheers,
Rodrigo.

==================================================================
(my ads code)

[lua]–Create the Ads-Inneractive (CoronaSDK) setup
local adNetwork = “inneractive”

local model = system.getInfo(“model”)

if model == “iPhone” or model == “iPod touch” or model == “iPhone Simulator” then
iPhone_appID = “myAppID”
ads.init( adNetwork, iPhone_appID )
ads.show( “banner”, { x=0, y=(H/1.12)-49, interval=35 } )[/lua] [import]uid: 89165 topic_id: 19981 reply_id: 79613[/import]

Has anyone come across this problem? I’m trying to serve iPhone banners to my iPad app, because 766x66 is too large for my real estate. So I’m initializing the ads module with my iPhone appId as set in the inner-active dashboard, but its still serving a 766x66 banner.

This is the code for showing the ad:

  
local showAd = function( adType )  
 --adType is set to "banner"  
 local adX, adY = 275,0  
 ads.show( adType, { x=adX, y=adY, interval=60, testMode=true } ) -- standard interval for "inneractive" is 60 seconds  
end  
  

And this is what results:

http://i.imgur.com/C29y4.png
Also, it seems to be ignoring the x/y position, and setting it to (0,0).

I’ve looked all over the forums, through sample code, and had some correspondence with Orly, but I still can’t figure it out. Does anyone know how to request a banner of a specific size and position it? What parameters does ads.show take that I’m not using?

Orly says the following sizes are supported: 200X50, 320X53, 216X36, 168X28, 120X20

[import]uid: 120 topic_id: 19981 reply_id: 79625[/import]

Rodrigo, where did you put the require “ads”?
My code is like this at the bottom of main after the intro part is all loaded.
I can’t be simpler than this…but still it does not show.
local ads = require “ads”

–Initialize ads
ads.init( “inneractive”, “MyCompanyName_MyGameName_iPad” )

– display banner ads
if( system.getInfo(“environment”) == “simulator” ) then
print (“simulator”)
local banner1 = display.newRect( 0, 0, 766, 66 )
banner1:setFillColor(255, 255, 255)
else
ads.show( “banner”, { x=0, y=0, interval=30} )
end [import]uid: 32063 topic_id: 19981 reply_id: 79626[/import]

@Luciane,

That looks correct as long as MyCompanyName_MyGameName_iPad matches the Inneractive App name in their Dashboard. It does a case sensitive comparison so make sure you use the Edit button next to your app name in the Dashboard, then copy from the popup to the clipboard, and paste it into your app.

From what I can tell, you have already done this. So you might want to add the following code just to be 100% sure your app is connected to the network:

[lua]local ads = require “ads”

local isSimulator = system.getInfo(“environment”) == “simulator”

function testNetworkConnection()
local netConn = require(‘socket’).connect(‘www.apple.com’, 80)
if netConn == nil then
return false
end
netConn:close()
return true
end

–Initialize ads
ads.init( “inneractive”, “MyCompanyName_MyGameName_iPad” )

– display banner ads
if( isSimulator or not testNetworkConnection() ) then
print (“simulator”)
local banner1 = display.newRect( 0, 0, 766, 66 )
banner1:setFillColor(255, 255, 255)
else
ads.show( “banner”, { x=0, y=0, interval=30} )
end[/lua] [import]uid: 16734 topic_id: 19981 reply_id: 79629[/import]

@bryan.vaccaro,

I’m seeing the same thing as you for ad sizes. It doesn’t seem to matter what appid you use. It seems like the underlying code is checking for device type and then serving up an add based on that. [import]uid: 67839 topic_id: 19981 reply_id: 79634[/import]

That does seem to be the case, it looks like when I switch the simulator to iPhone 4 it’s getting a smaller ad (although stretched to compensate for the retina display resolution).
I can probably work around this by placing the ad somewhere else or not at all, but I hope they fix this issue. [import]uid: 120 topic_id: 19981 reply_id: 79635[/import]

@Luciane Yes, you`re right! I did not mention those in my code because they are obligatory and so I know you knew that. :slight_smile:

BTW @Ken have done it all clean for you and so I believe youll get it, if not, tell here. **@bryan** Ive had a problem like yours when I was trying to get iPhone banners on the iPad as well as it would “fit” my project better, BUT I gave that UP after so much tries and gotting nothing as you`re mentioning too. :\
Cheers,
Rodrigo.

[import]uid: 89165 topic_id: 19981 reply_id: 79641[/import]