Moving Off Inneractive Back to AdMob

oops forgot one :slight_smile:

  1. Although its good to be able to reposition the ad with a remote config file, i don’t think its really that necessary. The main problem with only allowing the x/y to be set remotely is that you can’t use things like (display.contentHeight - display.screenOriginY) to pin the ad to the bottom of the screen. I guess I can just overide the x/y in my code after calling your initfromurl.

Aside from those issues the only other ones are the standard ones with the webpopup - you can’t actually be sure how big the ad is inside the popup and you often end up with a black border on larger devices :frowning: [import]uid: 8872 topic_id: 22182 reply_id: 88427[/import]

@kam187

1-2) Instead of calling error() function (and stopping further application execution…) now i simply return from the event listener. Ad system will not work, but application continue to run. Its better than before i guess.

  1. I implemented AdMediator.setPosition() function. I also made x and y configuration parameters optional. If you want to set ad position manually, call setPosition() before calling initFromUrl() and dont specify x and y in your configuration file. x,y parameters in config file always override manually set positions.

you can now pull those updates from github. [import]uid: 11686 topic_id: 22182 reply_id: 88482[/import]

cool :slight_smile: will check it out tomorrow!

This is looking like a great module, and i’ll tweet about it once i release. [import]uid: 8872 topic_id: 22182 reply_id: 88523[/import]

Just tested it, and although there’s no lua error when init fails from url, .show errors because currentNetworkIdx is nil.

I think the init should return true/false to indicate weather it initialised properly or not. This would give the app the option to try again later.

I think all the other methods like .hide, .show etc should also just return silently (or with true/false i guess) if the ad module’ isn’t initialised.
[import]uid: 8872 topic_id: 22182 reply_id: 88639[/import]

Btw i think you also should have:

local json = require(“json”)

instead of just require(“json”) [import]uid: 8872 topic_id: 22182 reply_id: 88651[/import]

I added ‘initialized’ flag. show(), hide() and start() functions now will not continue if admediator was not initialized. They also return false in such a situation. I also included json as a local table, so its more memory efficient now :slight_smile: [import]uid: 11686 topic_id: 22182 reply_id: 88661[/import]

Great :slight_smile:

One more…

 if params.enabled == nil then  
 params.enabled = true  
 elseif params.enabled == false or params.enabled == "false" then  
 params.enabled = false  
 return  
 end  

you should probably check for “false” since the remote config file is written like “enabled” : “false”

I’m also looking at the scaleing not working inside web popups on certain networks. It looks like admob scales upto 1.5 times, the rest wont scale up at all.

One last thing… I think you should store the timer handle and start/cancel in show/hide:

Move this to .show

 fetchRandomNetwork()  
 timer\_handle = timer.performWithDelay( adRequestDelay \* 1000, fetchRandomNetwork, 0 )  

and in .hide put

 timer.cancel( timer\_handle )  

This way you can init everything, in your game code at the begining, and only show the ad when you’re ready by calling .show [import]uid: 8872 topic_id: 22182 reply_id: 88666[/import]

no, you should write it as “enabled” : false. Its a boolean value not a string.

I just pause the timer when hide() is called, and resume it in show(). Now its better.
[import]uid: 11686 topic_id: 22182 reply_id: 88672[/import]

Finally fixed the scaling issues on iPad and android!

A quick explanation…

Inneractive and inMobi (but not Admob) send you content back with a viewport meta tag already present with scale = 1. I use a find/replace to change the meta name “viewport” to “viewport_dummy”. This lets you use your own viewport meta data.

Since the ads are served at 320x48 the existing meta tag you had without any scaling works fine for iPhones and iTouch devices.

For the iPad, you need to ad a scale parameter to make it scale up correctly. I calculate it from the content scaling since the type of scaling may be different for different apps.

For Android, the phone scales automatically up to a scale of 2x (thats the max). So, if the scale for the current device is > 2 you need to reduce the webpopup size accordingly. Unfortunately you can’t set the scale as you do with the iPad, as high density displays on ICS automatically set an additional scale factor.

Tested on iPad, iPhone, Android 4.0 (ICS) and Android 2.3 with admob, inMobi and inner-active :slight_smile:

[code]
local function displayContentInWebPopup(x,y,width,height,contentHtml)

local filename = “webview.html”
local path = system.pathForFile( filename, system.TemporaryDirectory )
local fhandle = io.open(path,“w”)
– Default for iPhone/iTouch
local meta = “”

local newX = x
local newY = y
local newWidth = 320
local newHeight = 50
local scale = 1/display.contentScaleY

– Remove any existing viewpoint
contentHtml = string.gsub(contentHtml, ““viewport””, ““dummy_viewport””)

if system.getInfo( “platformName” ) == “Android” then
meta = “”
– Max scale for android is 2 (enforced above just in case), so adjust web popup if over 2.
if scale > 2 then scale = scale/2
newWidth = (width/scale) + 1
newHeight = (height/scale) + 2
newX = x + (width - newWidth)/2
newY = y + (height - newHeight)/2
end

elseif system.getInfo( “model” ) == “iPad” or system.getInfo( “model” ) == “iPad Simulator” then
meta = “”
end

local bodyStyle = “”
fhandle:write("[html]"…meta…""…bodyStyle…contentHtml…"[/html]")
io.close(fhandle)

local function webPopupListener( event )
if string.find(event.url, “file://”, 1, false) == 1 then
return true
else
system.openURL(event.url)
end
end

local options = { hasBackground=false, baseUrl=system.TemporaryDirectory, urlRequest=webPopupListener }

– native.showWebPopup( x, y, width, height, filename…"?"…os.time(), options)
native.showWebPopup( newX, newY, newWidth, newHeight, filename…"?"…os.time(), options)

webPopupVisible = true
currentWebPopupContent = contentHtml

end
[/code] [import]uid: 8872 topic_id: 22182 reply_id: 88758[/import]

hey kam, i updated the code as you suggested. your support is invaluable, thank you.

I also changed the logic of initFromUrl mechanism. No you should give it a additional initCallbackFunction. AdMediator will call it when initialization is completed with a status flag which will be true or false. After you receive this callback, you should manually call AdMediator.start(). This will be a better approach i guess. Sample code is here:

[code]
local function initCallback(initialized)
if initialized then
AdMediator.start()
else
print(“ERROR: AdMediator can not initialized properly!”)
end
end

AdMediator.initFromUrl("http://yourserver/admediator-init.config?"..os.time(), initCallback)
[/code] [import]uid: 11686 topic_id: 22182 reply_id: 88828[/import]

this is some great stuff, i will check it out next week, thanks guys! [import]uid: 90610 topic_id: 22182 reply_id: 88842[/import]

Hey Deniz,

I see you made lots of new changes on github - nice!

Are you planning to add any new networks? The only other big one I think is leadbolt. As always some people say its good and others say its not, but with remote config I’d rather add it and just turn it on/off as i need.

I’m going to update my game in a few days, so just wondering if i should wait for any big changes you might have planned.

Kam [import]uid: 8872 topic_id: 22182 reply_id: 89653[/import]

hey kam,

I am not planning to add more networks soon, but the next one on my list is applifier. Its the biggest cross-promotion network as far as i know.

There are no known bugs on current master branch. I also sent my next application update using this version. But anyway, dont forget to test your app extensively :slight_smile: [import]uid: 11686 topic_id: 22182 reply_id: 89664[/import]

Everyone should really give LunarAds a try. http://LunarAds.com - made for Corona :slight_smile:

We are adding 3 new ad networks this week!

[import]uid: 9046 topic_id: 22182 reply_id: 90348[/import]

MBD, I would, but the networks you support right now aren’t that great.

Is your page out of date maybe? Do you support admob now? Which networks exactly do you support and what are the three new one?

Kam

[import]uid: 8872 topic_id: 22182 reply_id: 90504[/import]

Currently we support the following networks:

Admob (banners)
Leadbolt (banners and app walls)
Tapit (banners)
LunarAds (cross promotion banners, or self promotion banners)
Pontiflex
JumptTap (coming today)

We should have 10 networks to choose from by next week as well. [import]uid: 9046 topic_id: 22182 reply_id: 90505[/import]

I have been using Tapit for advertising and the ecpm so far has been great…over $1.80…the fill has been on the low though…they say its because most of the traffic on my site is coming from other countries [import]uid: 130487 topic_id: 22182 reply_id: 90562[/import]

Nice work on Ad Mediator, Deniz. Thanks for making the code available. I’m going to try it out in an update to one of my apps shortly. [import]uid: 1560 topic_id: 22182 reply_id: 90604[/import]

@Dotnaught, why not give LunarAds a try?

Richard [import]uid: 9046 topic_id: 22182 reply_id: 90636[/import]

MBD, Any plans to support inner-active at all?

How are you pulling the ads btw? Do you use network.request or a webpopup to a url on your site?

I ask because on the old 319 build (needed for support of arm6 android), network.request isn’t working :confused: [import]uid: 8872 topic_id: 22182 reply_id: 90727[/import]