Looking to post ads on my app but stuck finding the correct code from inneractive sample project in corona.

I want to put ads in my free app. I understand the call button to show ads within the simulator. As I was condensing the code I got stuck as to what was important and what was not, ie; (what code was dependant on the widget library. I only need one button and that is to ask to pay for a app without ads.
Heres the code so far.Thanks

[code]
–==================================================================================================
– INITIAL SETTINGS

– hide the status bar:
display.setStatusBar( display.HiddenStatusBar )
– Below is the ad network that will be used:

local adNetwork = “inneractive”

– Replace nil below with your app ID:
– String; e.g. surrounded by quotes (ex. “abcdefghijklmnop”)

local appID = nil

–==================================================================================================

– Make Banner Ads features available under “ads” namespace
local ads = require “ads”

– Create a text object to display ad status
local statusText = display.newRetinaText( “”, 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160

– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

– initialize ad network:
ads.init( adNetwork, appID, adListener )

– localize a widget function
local widget = require “widget”
widget.setTheme( “theme_ios” )

– initial variables
local sysModel = system.getInfo(“model”)
local sysEnv = system.getInfo(“environment”)
– Shows a specific type of ad
local showAd = function( adType )
local adX, adY = 0, 0
statusText.text = “”
ads.show( adType, { x=adX, y=adY, interval=60, testMode=true } ) – standard interval for “inneractive” is 60 seconds
end

– event listener for widget buttons
local function onButtonRelease( event )
local id = event.target.id

if id == “hideAll” then
ads.hide()
statusText.text = “”
else
showAd( id )
end
end

– if on simulator, make sure onRelease listeners for buttons are reset to nil
if sysEnv == “simulator” then onButtonRelease = nil; end

– create show banner ad button
local bannerButton = widget.newButton{
id = “banner”,
label = “Show Banner Ad”,
labelColor = { default={255}, over={0} },
style = “sheetBlack”,
onRelease = onButtonRelease
}
bannerButton:setReferencePoint( display.CenterReferencePoint )
bannerButton.x = display.contentWidth * 0.5
bannerButton.y = display.contentHeight - 240

– create text ad button
local textButton = widget.newButton{
id = “text”,
label = “Show Text Ad”,
labelColor = { default={0}, over={0} },
style = “sheetGreen”,
onRelease= onButtonRelease
}
textButton:setReferencePoint( display.CenterReferencePoint )
textButton.x = display.contentWidth * 0.5
textButton.y = display.contentHeight - 180

– create fullscreen ad button
local fullScreenButton = widget.newButton{
id = “fullscreen”,
label = “Show Fullscreen Ad”,
labelColor = { default={0}, over={0} },
style = “sheetYellow”,
onRelease= onButtonRelease
}
fullScreenButton:setReferencePoint( display.CenterReferencePoint )
fullScreenButton.x = display.contentWidth * 0.5
fullScreenButton.y = display.contentHeight - 120

– create a hide all ads button
local hideButton = widget.newButton{
id = “hideAll”,
label = “Hide All Ads”,
labelColor = { default={0}, over={0} },
style=“sheetRed”,
onRelease= onButtonRelease
}
hideButton:setReferencePoint( display.CenterReferencePoint )
hideButton.x = display.contentWidth * 0.5
hideButton.y = display.contentHeight - 60

– start with banner ad
showAd( “banner” )
end

[/code] [import]uid: 88495 topic_id: 34715 reply_id: 334715[/import]

Line 47 and the function at line 59.

The button to link to your paid version is up to you.

Try taking the code from the sample app and removing even the widget code. Your starting point should be removing the widget require. [import]uid: 8271 topic_id: 34715 reply_id: 137916[/import]

Updated the code but no luck getting it to run.

[code]
display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar

– Below is the ad network that will be used:

local adNetwork = “inneractive”

– Replace nil below with your app ID:
– String; e.g. surrounded by quotes (ex. “abcdefghijklmnop”)

local appID = nil

–==================================================================================================

– Make Banner Ads features available under “ads” namespace
local ads = require “ads”

– Create a text object to display ad status
local statusText = display.newRetinaText( “”, 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160

– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

– initialize ad network:
ads.init( adNetwork, appID, adListener )

– initial variables
local sysModel = system.getInfo(“model”)
local sysEnv = system.getInfo(“environment”)
– Shows a specific type of ad
local showAd = function( adType )
local adX, adY = 0, 0
statusText.text = “”
ads.show( adType, { x=adX, y=adY, interval=60, testMode=true } ) – standard interval for “inneractive” is 60 seconds
end
– start with banner ad
showAd( “banner” )
end

local BSound = audio.loadSound( “songplay.mp3” )
audio.play(BSound)
local director = require (“director”)
–> Requires director

local mainGroup = display.newGroup()
–> Creates the main group

local function main()
–> Adds main function

mainGroup:insert(director.directorView)
–> Adds the group from director

director:changeScene(“menu”)
–> Change the scene, no effects

return true

end

main()
–> Starts our app

[code] [import]uid: 88495 topic_id: 34715 reply_id: 137918[/import]

Is

[code]

’ expected near ‘end’
[/code]

something general or something specific? [import]uid: 88495 topic_id: 34715 reply_id: 137920[/import]

Okay this works, but not sure how to add the ad’s

[code]
display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar

– Below is the ad network that will be used:

local adNetwork = “inneractive”

– Replace nil below with your app ID:
– String; e.g. surrounded by quotes (ex. “abcdefghijklmnop”)

local appID = nil

–==================================================================================================

– Make Banner Ads features available under “ads” namespace
local ads = require “ads”

– Create a text object to display ad status
local statusText = display.newRetinaText( “”, 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160

– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

– initialize ad network:
ads.init( adNetwork, appID, adListener )

– initial variables
local sysModel = system.getInfo(“model”)
local sysEnv = system.getInfo(“environment”)
– Shows a specific type of ad
local showAd = function( adType )
local adX, adY = 0, 0
statusText.text = “”
ads.show( adType, { x=adX, y=adY, interval=60, testMode=true } ) – standard interval for “inneractive” is 60 seconds
end
– start with banner ad
showAd( “banner” )
local BSound = audio.loadSound( “songplay.mp3” )
audio.play(BSound)
local director = require (“director”)
–> Requires director

local mainGroup = display.newGroup()
–> Creates the main group

local function main()
–> Adds main function

mainGroup:insert(director.directorView)
–> Adds the group from director

director:changeScene(“menu”)
–> Change the scene, no effects

return true

end

main()
–> Starts our app

[/code] [import]uid: 88495 topic_id: 34715 reply_id: 137927[/import]

Okay, I guess the “Play for Charity” banner showed up when I built for the device. Any leads as to how I would build a little button at the bottom to remove the ads. I’d like one of those alerts to pop up and ask to purchase or not.Thanks.

P.S.

I found end after show “ads” and removed that to get a function to start.Thanks horacebury. [import]uid: 88495 topic_id: 34715 reply_id: 137930[/import]

Is there a way to change the location the banner shows? [import]uid: 88495 topic_id: 34715 reply_id: 137935[/import]

Is this ad listener still required for ad to run properly? Can event table and event.provider be un-commented to use within the code or is that only a comment.

[code]
– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

[/code] [import]uid: 88495 topic_id: 34715 reply_id: 137936[/import]

The lines in green are comments. Comments can also be in the form:
[lua]–[[comment here]]-[/lua]

Can you say exactly what you are trying to do? It sounds like you should be creating a very simple main.lua with nothing but an ad displayed. Then you should run that in the XCode simulator.

I’ve not done much with ads, but I found it pretty straightforward. Take it back to basics… [import]uid: 8271 topic_id: 34715 reply_id: 137939[/import]

I’ve got the ad to run in my app. My next step is to get a inneractive account so I can change the local appID = nil to a app id. But my issue im getting is the banner takes up space that I need for the app to work. Do i have to change design or can I shorten the banner space?Right now I dont see insertion quotes like I see for inMobi.Thanks. [import]uid: 88495 topic_id: 34715 reply_id: 137941[/import]

Could you also take a look at my inMobi code?
I’m getting a blank screen for the build on device.
Also, the terminal tells me Retina.Text is deprecated but I don’t see the code anywhere in my main.lua file. Is that just a comment for the Corona SDK build?Thanks

[code]
–==================================================================================================

– Abstract: InMobi Ads Sample Project

– This project demonstrates Corona Banner Ads support (from inmobi network).

– IMPORTANT: You must get your own “app ID” from the advertising
– agency you want to display banner ads for. Further, you must build for device
– to properly test this sample, because “ads” library is not supported by the
– Corona Simulator.

– 1. Get your app ID (example, from inmobi)
– 2. Modify the code below to use your own app ID
– 3. Build and deploy on device

– The code below demonstrates the different banner ads you can use
– with the InMobi ad network.


– Version: 1.0 (July 7, 2011)
– Version: 1.1 (July 22, 2011) - Added Hide button and changed Next button behavior.

– Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
– Copyright © 2011 Corona Labs Inc. All Rights Reserved.

–==================================================================================================
–==================================================================================================
– INITIAL SETTINGS

– hide the status bar:
display.setStatusBar( display.HiddenStatusBar )
– Below is the ad network that will be used:

local adNetwork = “inmobi”

– Replace nil below with your app ID:
– String; e.g. surrounded by quotes (ex. “abcdefghijklmnop”)

local appID = nil

–==================================================================================================

– Make Banner Ads features available under “ads” namespace
local ads = require “ads”

– initialize ad network:
if appID then
ads.init( adNetwork, appID )
end
local bgW, bgH = 320, 480
local currentAdIndex = 1

local adsTable = {
“ad1.png”,
“ad2.png”,
}
if sysModel == “iPad” then
– change settings if on iPad. It has 3 additional adUnitTypes it can show.
bgW, bgH = 768, 1024
adsTable = {
“ad1.png”,
“ad2.png”,
“banner728x90”,
“banner468x60”,
“banner120x600”
}
end
– change settings if on iPad
if sysModel == “iPad” then
bgW, bgH = 768, 1024
end

if appID then
– Shows the banner indexed by variable “currentAdIndex”
local showIndexedBanner = function()
print("Showing Banner: " … adsTable[currentAdIndex])
local adX, adY = 0, 0
ads.show( adsTable[currentAdIndex], { x=adX, y=adY, interval=5, testMode=true } )
end

end

[/code] [import]uid: 88495 topic_id: 34715 reply_id: 137947[/import]

Line 47 and the function at line 59.

The button to link to your paid version is up to you.

Try taking the code from the sample app and removing even the widget code. Your starting point should be removing the widget require. [import]uid: 8271 topic_id: 34715 reply_id: 137916[/import]

Updated the code but no luck getting it to run.

[code]
display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar

– Below is the ad network that will be used:

local adNetwork = “inneractive”

– Replace nil below with your app ID:
– String; e.g. surrounded by quotes (ex. “abcdefghijklmnop”)

local appID = nil

–==================================================================================================

– Make Banner Ads features available under “ads” namespace
local ads = require “ads”

– Create a text object to display ad status
local statusText = display.newRetinaText( “”, 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160

– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

– initialize ad network:
ads.init( adNetwork, appID, adListener )

– initial variables
local sysModel = system.getInfo(“model”)
local sysEnv = system.getInfo(“environment”)
– Shows a specific type of ad
local showAd = function( adType )
local adX, adY = 0, 0
statusText.text = “”
ads.show( adType, { x=adX, y=adY, interval=60, testMode=true } ) – standard interval for “inneractive” is 60 seconds
end
– start with banner ad
showAd( “banner” )
end

local BSound = audio.loadSound( “songplay.mp3” )
audio.play(BSound)
local director = require (“director”)
–> Requires director

local mainGroup = display.newGroup()
–> Creates the main group

local function main()
–> Adds main function

mainGroup:insert(director.directorView)
–> Adds the group from director

director:changeScene(“menu”)
–> Change the scene, no effects

return true

end

main()
–> Starts our app

[code] [import]uid: 88495 topic_id: 34715 reply_id: 137918[/import]

Is

[code]

’ expected near ‘end’
[/code]

something general or something specific? [import]uid: 88495 topic_id: 34715 reply_id: 137920[/import]

Okay this works, but not sure how to add the ad’s

[code]
display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar

– Below is the ad network that will be used:

local adNetwork = “inneractive”

– Replace nil below with your app ID:
– String; e.g. surrounded by quotes (ex. “abcdefghijklmnop”)

local appID = nil

–==================================================================================================

– Make Banner Ads features available under “ads” namespace
local ads = require “ads”

– Create a text object to display ad status
local statusText = display.newRetinaText( “”, 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160

– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

– initialize ad network:
ads.init( adNetwork, appID, adListener )

– initial variables
local sysModel = system.getInfo(“model”)
local sysEnv = system.getInfo(“environment”)
– Shows a specific type of ad
local showAd = function( adType )
local adX, adY = 0, 0
statusText.text = “”
ads.show( adType, { x=adX, y=adY, interval=60, testMode=true } ) – standard interval for “inneractive” is 60 seconds
end
– start with banner ad
showAd( “banner” )
local BSound = audio.loadSound( “songplay.mp3” )
audio.play(BSound)
local director = require (“director”)
–> Requires director

local mainGroup = display.newGroup()
–> Creates the main group

local function main()
–> Adds main function

mainGroup:insert(director.directorView)
–> Adds the group from director

director:changeScene(“menu”)
–> Change the scene, no effects

return true

end

main()
–> Starts our app

[/code] [import]uid: 88495 topic_id: 34715 reply_id: 137927[/import]

Okay, I guess the “Play for Charity” banner showed up when I built for the device. Any leads as to how I would build a little button at the bottom to remove the ads. I’d like one of those alerts to pop up and ask to purchase or not.Thanks.

P.S.

I found end after show “ads” and removed that to get a function to start.Thanks horacebury. [import]uid: 88495 topic_id: 34715 reply_id: 137930[/import]

Is there a way to change the location the banner shows? [import]uid: 88495 topic_id: 34715 reply_id: 137935[/import]

Is this ad listener still required for ad to run properly? Can event table and event.provider be un-commented to use within the code or is that only a comment.

[code]
– Set up ad listener.
local function adListener( event )
– event table includes:
– event.provider (e.g. “inneractive”)
– event.isError (e.g. true/false )

if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = “Error Loading Ad”
statusText.x = display.contentWidth * 0.5
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = “Successfully Loaded Ad”
statusText.x = display.contentWidth * 0.5
end
end

[/code] [import]uid: 88495 topic_id: 34715 reply_id: 137936[/import]

The lines in green are comments. Comments can also be in the form:
[lua]–[[comment here]]-[/lua]

Can you say exactly what you are trying to do? It sounds like you should be creating a very simple main.lua with nothing but an ad displayed. Then you should run that in the XCode simulator.

I’ve not done much with ads, but I found it pretty straightforward. Take it back to basics… [import]uid: 8271 topic_id: 34715 reply_id: 137939[/import]

I’ve got the ad to run in my app. My next step is to get a inneractive account so I can change the local appID = nil to a app id. But my issue im getting is the banner takes up space that I need for the app to work. Do i have to change design or can I shorten the banner space?Right now I dont see insertion quotes like I see for inMobi.Thanks. [import]uid: 88495 topic_id: 34715 reply_id: 137941[/import]