Banner ads busted on iPhone 5

Banner ads aren’t displaying properly when I test them on an iPhone 5. They don’t appear at the coordinates I choose. They mostly work on an iPad Retina, although I’m still having trouble getting them centered. I have a Universal app, so how do I get banners to display at the same location across devices? [import]uid: 35706 topic_id: 37482 reply_id: 67482[/import]

When you say that they don’t appear at the coordinates you choose, where are they appearing? It would be helpful if you posted (a) the code you’re using to display the ad, and (b) a screenshot showing where the ad is actually appearing.

  • Andrew [import]uid: 109711 topic_id: 37482 reply_id: 145666[/import]

This is what I’m doing to try to get the banner centered on-screen:

 

local adX, adY = display.contentWidth / 2, display.contentHeight / 2 ads.init( "inneractive", "appID" ) local showAd = function(adType) ads.show(adType, { x=adX, y=adY, interval=60 } ) end showAd( "banner" )

 

The banner doesn’t appear at all.

Hi there,

 

Thanks for sharing the code.

 

I have two suggestions:

  1. The x,y coordinates that you pass to ads.show() actually represent the upper-left corner of the ad, not the center.  So you’ll have to do a little math, based on the size of the ad, if you want to actually have it centered on screen.  Of course, that still doesn’t explain why you’re not seeing an ad at all
  2. To help understand why you’re not seeing an ad at all, you should add a listener to your ads.init() call.  See an example at http://docs.coronalabs.com/api/library/ads/init.html.  This way, you’ll be able to see if the ad request resulted in an error, i.e. the appID wasn’t recognized, or there were no ads available at the time
  • Andrew

Thanks. Fortunately I know the ads are working because if I leave the x,y coordinates at 0 then the banner shows up in the upper left hand corner. But changing the coordinates to most anything else hides the banner offscreen somewhere.

 

I think the problem is that the banners don’t scale like everything else that’s displayed. If I change x to something small like 20 then the banner moves a lot on an iPhone but much less on an iPad. I just want to be able to align the banner centered and along the bottom of the screen. But it looks like this isn’t possible with a Universal app. Or if it is possible, I haven’t figured out how.

Hi there,

 

Thanks for the extra info.  It certainly is possible to get the banner to appear centered on the bottom for a universal app.  What does your config.lua file look like – are you using one of the dynamic content scaling modes (such as letterbox)?

 

  • Andrew

Yes, I’m using zoomStretch.

I think you have to use absolute values to place inneractive banners, based on the screensize of the device - at least you used to, before I switched to using adMediator to implement inneractive.

 

I used something like this to place banners at the bottom:

 

[lua]

 

local device = system.getInfo(“model”)

local ady

local adx

 

local isTall = ( “iPhone” == system.getInfo( “model” ) ) and ( display.pixelHeight > 960 )

 

if string.sub(device, 1, 4) == “iPad” then

ady = 950; adx = 40

 

  else

 

ady = 430

adx = 0

 

if isTall == true then ady = 530; end

 

end

 

 

ads.show(“banner”, { x = adx, y = ady, interval = 180 })

 

[/lua]

When you say that they don’t appear at the coordinates you choose, where are they appearing? It would be helpful if you posted (a) the code you’re using to display the ad, and (b) a screenshot showing where the ad is actually appearing.

  • Andrew [import]uid: 109711 topic_id: 37482 reply_id: 145666[/import]

This is what I’m doing to try to get the banner centered on-screen:

 

local adX, adY = display.contentWidth / 2, display.contentHeight / 2 ads.init( "inneractive", "appID" ) local showAd = function(adType) ads.show(adType, { x=adX, y=adY, interval=60 } ) end showAd( "banner" )

 

The banner doesn’t appear at all.

Hi there,

 

Thanks for sharing the code.

 

I have two suggestions:

  1. The x,y coordinates that you pass to ads.show() actually represent the upper-left corner of the ad, not the center.  So you’ll have to do a little math, based on the size of the ad, if you want to actually have it centered on screen.  Of course, that still doesn’t explain why you’re not seeing an ad at all
  2. To help understand why you’re not seeing an ad at all, you should add a listener to your ads.init() call.  See an example at http://docs.coronalabs.com/api/library/ads/init.html.  This way, you’ll be able to see if the ad request resulted in an error, i.e. the appID wasn’t recognized, or there were no ads available at the time
  • Andrew

Thanks. Fortunately I know the ads are working because if I leave the x,y coordinates at 0 then the banner shows up in the upper left hand corner. But changing the coordinates to most anything else hides the banner offscreen somewhere.

 

I think the problem is that the banners don’t scale like everything else that’s displayed. If I change x to something small like 20 then the banner moves a lot on an iPhone but much less on an iPad. I just want to be able to align the banner centered and along the bottom of the screen. But it looks like this isn’t possible with a Universal app. Or if it is possible, I haven’t figured out how.

Hi there,

 

Thanks for the extra info.  It certainly is possible to get the banner to appear centered on the bottom for a universal app.  What does your config.lua file look like – are you using one of the dynamic content scaling modes (such as letterbox)?

 

  • Andrew

Yes, I’m using zoomStretch.

I think you have to use absolute values to place inneractive banners, based on the screensize of the device - at least you used to, before I switched to using adMediator to implement inneractive.

 

I used something like this to place banners at the bottom:

 

[lua]

 

local device = system.getInfo(“model”)

local ady

local adx

 

local isTall = ( “iPhone” == system.getInfo( “model” ) ) and ( display.pixelHeight > 960 )

 

if string.sub(device, 1, 4) == “iPad” then

ady = 950; adx = 40

 

  else

 

ady = 430

adx = 0

 

if isTall == true then ady = 530; end

 

end

 

 

ads.show(“banner”, { x = adx, y = ady, interval = 180 })

 

[/lua]