Hi,
In my app I am using Inmobi test-ads to test my ad-code (I have added that code below, although it is nothing special).
For that I am using the test-ID they provide (see below, in the code). I am testing both on an Android device (Samsung 7 inch tablet) and on 2 iOS devices (mini-iPad and iPod).
I had it working yesterday and the day before but maybe not so today anymore (without having changed any code for the last 2 days). At least, ad-requests are sent to Inmobi but there is no reaction.
In the hope to get some clue I connected the devices to my Mac and logged them (XCode-console for iOS, adb logcat for Android). I didn’t find a clue. Though I’ve find something else: on the Android device (but not so on the iOS devices) the ad-requests continued to be sent when the app was in the background, and even when the device idled (and the screen was dark). Those requests could only be stopped by forcing the app to stop or by switching off the device.
Here my questions:
-
IMO it doesn’t make any sense to keep on sending ad-requests when the app is in the background or when the device idles. It gives an unnecessary load to the system for an ad you won’t see. Is there a way to stop the ad-requests when, for some reason or another, the ad is not active?
-
a related question: does someone know why the ads stopped coming. Something I can do about it?
-
a less related question: my config.lua is as in the Inmobi ad sample code.
On the iPod and the iPad the banner extend over (almost) the full width of the screen, but on the Android device, in spite of the config.lua which “tells” that the tablet is only 320 pixels wide, the ad takes only half the devices width and clearly considers the tablet to be 600 pixels wide (its actual width). How can I change that?
Here is my code:
[lua]-- adLuaFile.lua
–[[
all the ad-code is in this file. Require “adLuaFile” in main.lua and add adLuaFile.adInitiate()
If you want an ad in a scene, require “adLuaFile” in that scene and add adLuaFile.adBegin() in
function scene:willEnterScene(event) or something and add adLuaFile.adEnd() in
function scene:exitScene(event) or something
–]]
local ads = require “ads”
local device = require “device” – (more or less) literally copied from Rob Miracle’s post
local adNetwerk = “inmobi”
–[[
test-ID for Inmobi, see:
developer.inmobi.com/wiki/index.php?title=Integration_Guidelines#Supported_Parameters_and_Slot_Sizes
More or less at the bottom of the page. Funny enough the Android-testID didn’t work on Android but
the iOS-testID did.
–]]
local appID = “4028cba631d63df10131e1d4650600cd”
local adListener, banner
local reclame1, reclame2 – for now: one of these 2 rectangles show if something goes wrong
local adX
local returnTable = {}
– DEVICE-DEPENDENT
if device.is_iPad == true then
banner = “banner728x90”
adX = 20
else
banner = “banner320x48”
adX = 0
end
– FUNCTIONS
function adListener(event)
local message = event.respons
if event.isError then
print("message!!!: "…message)
reclame1 = display.newRect(0, 0, 320, 48)
reclame1:setFillColor(255, 255, 0)
reclame1:toFront()
end
end
local function adInitiate()
ads.init(adNetwerk, appID, adListener)
print(“ads.init”)
return true
end
returnTable.adInitiate = adInitiate
local function adBegin()
if appID then
ads.show(banner, {x = adX, y = 0, testMode = true})
else
reclame2 = display.newRect(0, 0, 320, 48)
reclame2:setFillColor(255, 0, 0)
end
return true
end
returnTable.adBegin = adBegin
local function adEnd()
ads.hide()
if reclame1 then reclame1:removeSelf() reclame1 = nil end
if reclame2 then reclame2:removeSelf() reclame2 = nil end
return true
end
returnTable.adEnd = adEnd
return returnTable
[/lua]