iAds

@Naomi, Andrew:

Hey guys,

The multiprovider init works, given that you:

  1. first init all the providers you want to use, all at the same time:

ads.init( “iads”, appID, adListener )
ads.init( “inmobi”, appID, adListener )

  1. then switch the current provider as fitting the logic of your code, for example if the iAds network fails to deliver:

– if iads failed
ads:setCurrentProvider(“inmobi”)

Regarding the orientation, there’s only one active bug on that, the one Haakon signaled, which occurs when opening an interstitial ad in fullscreen and changing orientation, when dismissing the fullscreen ad the game view is not updated with the actual orientation. That’s still being worked on.
Hope this helps,
Alex. [import]uid: 196533 topic_id: 34226 reply_id: 144869[/import]

Hi Alex, thanks for the info!

Is the method setCurrentProvider documented anywhere? I hadn’t seen it in the API docs or daily build notes, but it’s the key ingredient I was missing.

  • Andrew [import]uid: 109711 topic_id: 34226 reply_id: 144875[/import]

Hi Andrew,

No, it’s not really documented yet. It’s been added and we’ve been testing it, we were waiting for some more things to couple with it, because it has extended functionality, not only ads-related.

If you need more info, feel free to ask, i’m here :slight_smile:

Alex.

[import]uid: 196533 topic_id: 34226 reply_id: 144876[/import]

Thanks Alex, that’s helpful. I’ll give it a try and let you know if I run into any issues.

  • Andrew [import]uid: 109711 topic_id: 34226 reply_id: 144886[/import]

That sounds great, Alex. Thank you for the info.

It sounds like what I need to do is to call ads.init of all ad providers I want in main.lua, and then call ads:setCurrentProvider in the module I want to show ads. My plan is to toggle among different ad providers – not just when one provider fails to deliver.

And if I haven’t misunderstood the way it works, I can show iAds banner on one screen and another ad provider’s full screen interstitial ad on another screen. This is important for me especially since iAds does not offer full screen interstitial ads for iPhone/iPod.

Thanks again.

Naomi

Edit: Actually, I will call ads.init of all ad providers in the module I want to show ads but I’ll include a flag to indicate whether or not the ads are already initialized. If it’s already initialized, I’d skip initializing the next time the user hit the screen. I think it would help avoid the ads-already-initialized warning. [import]uid: 67217 topic_id: 34226 reply_id: 144892[/import]

Hi Alex, I integrated both iAds and inneractive, using the method you described in post #63 above. The problem is, when I set the ads:setCurrentProvider to “inneractive”, I don’t get any adListener response. The inneractive fullscreen ads do appear, but my app doesn’t know that it has appeared, and it ends up hanging my app after I close the inneractive fullscreen ad. Is this a bug? Or am I doing something wrong? Please see below the relevant code that I extracted from mine and let me know your thoughts.

Naomi

Edit: incomplete code updated

[code]
– in main.lua
_G.initAds = false

– in menu.lua
local showAds = require( “showAds” )
if _G.initAds == false then showAds.startAds() end

– in showAds.lua
local M = {}
local adListener
local adType, adParam
local adX, adY, adInterval, adTest
function M.startAds()
_G.initAds = true;
local appID = “com.mycompany.myapp”
ads.init( “iads”, appID, adListener )

if (string.sub( myDevice.model,1,4) == “iPad”) then
appID = “mycompany_myapp_iPad”
ads.init( “inneractive”, appID, adListener )
else
appID = “mycompany_myapp_iPhone”
ads.init( “inneractive”, appID, adListener )
end
end
function adListener(event)
print("--------------- inside adListener ----------------")
– event table includes:
– event.provider (e.g. “inneractive” or “iads”)
– event.isError (e.g. true/false )
print("event.response = " … tostring(event.response))
print("event.provider = " … tostring(event.provider))
print("event.isError = " … tostring(event.isError))
print("adType = " … tostring(adType))
print("adNetwork = " … tostring(adNetwork))

if adType == “full” then
if event.isError then
ads.hide()
– show house ads here
else
– fullscreen interstitial ad is being displayed
– behind the screen, update my app to advance to the next screen
timer.performWithDelay( 2000, M.goNext )
end
else
– banner ads
end
end

function M.show(doNext)
M.goNext = doNext
adType = “full”
adNetwork = “inneractive”
adX=0; adY=0; adInterval=180; adTest=false;
adParam = “fullscreen”
ads:setCurrentProvider(adNetwork)

if adNetwork == “inneractive” then
ads.show( adParam, { x=adX, y=adY, interval=adInterval, testMode=adTest } )
end
end

– in a scene module where I want to show ads
local function nextScreen()
– here I have routine that advances the screen to the next screen that
– I want to show after the ads are closed
end
showAds.show( nextScreen )
[/code] [import]uid: 67217 topic_id: 34226 reply_id: 144991[/import]

Hi Naomi,

Hard to say what is causing the freezing. The listener part not getting events is for sure something in your code. I just tried this:

local ads = require( "ads" )  
  
local function adListener(event)  
 print("event.response = " .. tostring(event.response))  
 print("event.provider = " .. tostring(event.provider))  
 print("event.isError = " .. tostring(event.isError))  
end  
  
ads.init( "iads", "com.test.test", adListener )  
ads.init( "inneractive", "com.test.test", adListener )  
ads:setCurrentProvider("inneractive")  
ads.show( "banner", { x=0, y=0, interval=60 } )  
  
local function switchAds()  
 ads.hide()  
 ads:setCurrentProvider("iads")  
 ads.show( "banner", { x=0, y=0 } )  
end  
  
timer.performWithDelay( 5000, switchAds )  

as a small testbed, and it works perfectly.

As for the freezing part, i just moved from a screen to another while displaying a fullscreen inneractive ad, and that works. I am thinking maybe deallocating some variables that you should not. I would need to know exactly what you’re doing (like i change from main to level1 while maintaining the adview on the screen) and what are you using (storyboard, director, custom code) at least to know where to start thinking at.

Alex. [import]uid: 196533 topic_id: 34226 reply_id: 144994[/import]

Thank you, Alex. I use storyboard, and I don’t change scene before or after the ad is shown. When the showAds.show is called, most of the display objects on the scene is made invisible, and what nextScreen function does is to make them all back to be visible.

Do you think it might be more effective if I create a test case project and file it as a bug?

Naomi [import]uid: 67217 topic_id: 34226 reply_id: 144996[/import]

Hi Naomi,

That would be amazing, and please paste back the bug number here so i can have a look.

Thanks a lot :slight_smile:

What about the listener not receiving events? Did you sort that out?

Alex. [import]uid: 196533 topic_id: 34226 reply_id: 144998[/import]

Hi Alex, I just filed Case 21361.

The listener-not-receiving-events when “inneractive” is used as the adnetwork is the bug. I can use iads and revmob together without a problem, but when I use iads and inneractive together, the listener isn’t getting any response when it’s on iPod device.

Thanks for looking into this.

Naomi [import]uid: 67217 topic_id: 34226 reply_id: 144999[/import]

Hi Alex, I saw a post by heftyApps that mentions the same issue (but described differently) along with another crash issue here:

http://developer.coronalabs.com/forum/2013/03/06/inneractive-major-crash-issue-please-help

Naomi [import]uid: 67217 topic_id: 34226 reply_id: 145208[/import]

I’m wondering what the status might be with “multiple init and switch between ad.” It’s mentioned in the post #20 of this thread. If it’s not available, and if we want to switch between ad providers, do we call ads.init locally in a module every time we call ads.show? When we call ads.init with different ad providers, are we basically re-initializing the ads? I’m thinking of toggling between iAds, InMobi and inneractive. Has anyone tried this? Is it effective? Any oddity switching ad providers?

Also, I checked the daily build notes, but I haven’t located a mention of orientation bug fix. Is it yet to be fixed? (I’m using daily build 1041 now.)

Naomi [import]uid: 67217 topic_id: 34226 reply_id: 144839[/import]

Hi Naomi,

I experimented with this a bit and didn’t get it to work. If I remember right, after calling ads.init for one provider with one callback function, later calling another provider with another callback function, and then attempting to go back to the first provider, the log output noted that the first provider had already been initialized, and my requests went to the second provider. But I don’t think I tested it as carefully as I could have, so it may be possible after all.

On the second question, iAds do have the right orientation for me. Last I checked, inneractive didn’t, but that was before the recent fix for iAds, which maybe addressed the inneractive bug too.

  • Andrew

[import]uid: 109711 topic_id: 34226 reply_id: 144840[/import]

Hi Andrew,

Thank you for your reply post. It’s a bit worrisome. I haven’t implemented the switch part, but if I call ads.init every time I want to show ads, the console gives me warning. It feels a bit messy to me. But then, from what I hear, switching between ad providers is quite effective in getting most out of ad revenue. I hope I can work this out somehow…

About the orientation issue, glad to hear it’s working for you. My latest app is horizontal so I wanted to make sure things will go smoothly.

Thanks again,
Naomi [import]uid: 67217 topic_id: 34226 reply_id: 144842[/import]

@Naomi, Andrew:

Hey guys,

The multiprovider init works, given that you:

  1. first init all the providers you want to use, all at the same time:

ads.init( “iads”, appID, adListener )
ads.init( “inmobi”, appID, adListener )

  1. then switch the current provider as fitting the logic of your code, for example if the iAds network fails to deliver:

– if iads failed
ads:setCurrentProvider(“inmobi”)

Regarding the orientation, there’s only one active bug on that, the one Haakon signaled, which occurs when opening an interstitial ad in fullscreen and changing orientation, when dismissing the fullscreen ad the game view is not updated with the actual orientation. That’s still being worked on.
Hope this helps,
Alex. [import]uid: 196533 topic_id: 34226 reply_id: 144869[/import]

Hi Alex, thanks for the info!

Is the method setCurrentProvider documented anywhere? I hadn’t seen it in the API docs or daily build notes, but it’s the key ingredient I was missing.

  • Andrew [import]uid: 109711 topic_id: 34226 reply_id: 144875[/import]

Hi Andrew,

No, it’s not really documented yet. It’s been added and we’ve been testing it, we were waiting for some more things to couple with it, because it has extended functionality, not only ads-related.

If you need more info, feel free to ask, i’m here :slight_smile:

Alex.

[import]uid: 196533 topic_id: 34226 reply_id: 144876[/import]

Thanks Alex, that’s helpful. I’ll give it a try and let you know if I run into any issues.

  • Andrew [import]uid: 109711 topic_id: 34226 reply_id: 144886[/import]

That sounds great, Alex. Thank you for the info.

It sounds like what I need to do is to call ads.init of all ad providers I want in main.lua, and then call ads:setCurrentProvider in the module I want to show ads. My plan is to toggle among different ad providers – not just when one provider fails to deliver.

And if I haven’t misunderstood the way it works, I can show iAds banner on one screen and another ad provider’s full screen interstitial ad on another screen. This is important for me especially since iAds does not offer full screen interstitial ads for iPhone/iPod.

Thanks again.

Naomi

Edit: Actually, I will call ads.init of all ad providers in the module I want to show ads but I’ll include a flag to indicate whether or not the ads are already initialized. If it’s already initialized, I’d skip initializing the next time the user hit the screen. I think it would help avoid the ads-already-initialized warning. [import]uid: 67217 topic_id: 34226 reply_id: 144892[/import]

Hi Alex, I integrated both iAds and inneractive, using the method you described in post #63 above. The problem is, when I set the ads:setCurrentProvider to “inneractive”, I don’t get any adListener response. The inneractive fullscreen ads do appear, but my app doesn’t know that it has appeared, and it ends up hanging my app after I close the inneractive fullscreen ad. Is this a bug? Or am I doing something wrong? Please see below the relevant code that I extracted from mine and let me know your thoughts.

Naomi

Edit: incomplete code updated

[code]
– in main.lua
_G.initAds = false

– in menu.lua
local showAds = require( “showAds” )
if _G.initAds == false then showAds.startAds() end

– in showAds.lua
local M = {}
local adListener
local adType, adParam
local adX, adY, adInterval, adTest
function M.startAds()
_G.initAds = true;
local appID = “com.mycompany.myapp”
ads.init( “iads”, appID, adListener )

if (string.sub( myDevice.model,1,4) == “iPad”) then
appID = “mycompany_myapp_iPad”
ads.init( “inneractive”, appID, adListener )
else
appID = “mycompany_myapp_iPhone”
ads.init( “inneractive”, appID, adListener )
end
end
function adListener(event)
print("--------------- inside adListener ----------------")
– event table includes:
– event.provider (e.g. “inneractive” or “iads”)
– event.isError (e.g. true/false )
print("event.response = " … tostring(event.response))
print("event.provider = " … tostring(event.provider))
print("event.isError = " … tostring(event.isError))
print("adType = " … tostring(adType))
print("adNetwork = " … tostring(adNetwork))

if adType == “full” then
if event.isError then
ads.hide()
– show house ads here
else
– fullscreen interstitial ad is being displayed
– behind the screen, update my app to advance to the next screen
timer.performWithDelay( 2000, M.goNext )
end
else
– banner ads
end
end

function M.show(doNext)
M.goNext = doNext
adType = “full”
adNetwork = “inneractive”
adX=0; adY=0; adInterval=180; adTest=false;
adParam = “fullscreen”
ads:setCurrentProvider(adNetwork)

if adNetwork == “inneractive” then
ads.show( adParam, { x=adX, y=adY, interval=adInterval, testMode=adTest } )
end
end

– in a scene module where I want to show ads
local function nextScreen()
– here I have routine that advances the screen to the next screen that
– I want to show after the ads are closed
end
showAds.show( nextScreen )
[/code] [import]uid: 67217 topic_id: 34226 reply_id: 144991[/import]