iOS banner can be positioned incorrectly to the left

341 views
Skip to first unread message

BernieBresslaw

unread,
Mar 13, 2015, 10:22:14 AM3/13/15
to google-adm...@googlegroups.com
I have a problem with ads in my Unity app - smartbanners sometimes appear off to the left.
To track this down I have taken the 'HelloWorld' sample and run this on an ipad mini 2 with version 7 of the SDK & I get the same problem.
NOTE: This is the Vanilla sample project - no changes made (apart from adding add id)

Sometimes smartbanners are off to the left.
Doesn't seem to be related to the ad - I have seen one for Kindle display fine, then after a switch it goes wrong - same with M&S maternity wear.

The Hello world sample handles landscape and portrait and I have seen the posts about issues around landscape mode, but this goes wrong in portrait.

Any ideas?

iOS version 8.2 (also problem on 8.1 & 6)
XCode 6.1.1

iOS SDK 7 also present on 6.12.2 etc.

Works fine on Android.

Here's what is looks like....



Thanks in advance...

Dave

BernieBresslaw

unread,
Mar 13, 2015, 11:45:28 AM3/13/15
to google-adm...@googlegroups.com
Screen grab of result now attached.
...
IMG_0112.PNG

Ram Parameswaran (Mobile SDK Team)

unread,
Mar 16, 2015, 2:17:26 PM3/16/15
to google-adm...@googlegroups.com
When changing from one screen orientation to another you will need to request and display a new smart banner as the width is not adjusted automatically. 

- Ram

BernieBresslaw

unread,
Mar 16, 2015, 6:46:19 PM3/16/15
to google-adm...@googlegroups.com
Thanks for the reply Ram.
Is this necessary if my app only displays portrait mode?
In unity it is set to allow for auto-rotation but only portrait & portrait upside down - no landscape.
Does the admob code use its own orientation settings independent of the main app?
If so, is there no way for force the orientation of the smart banners to portrait?

Also, this only seems to be a problem for iOS - my android version is fine.
And only for smart banners.

Any advice appreciated.

Ram Parameswaran (Mobile SDK Team)

unread,
Mar 17, 2015, 3:15:58 PM3/17/15
to google-adm...@googlegroups.com
If the screen orientation does not change after a smart banner is requested, there should not be any issues with the banner positioning. The Unity plugin or ads SDK do not maintain screen orientation state separately. On the Android platform during an orientation change all assets are destroyed and re-created. Therefore the default behavior is to request and display a new smart banner after every orientation change. This is not the case for iOS. 

- Ran

BernieBresslaw

unread,
Mar 17, 2015, 6:05:42 PM3/17/15
to google-adm...@googlegroups.com
The physical orientation of the device may change, but the graphical orientation remains the same as I am only allowing portrait.
Applying this to the unity admob sample code (by forcing portrait mode), I get the same results - hold the device in landscape and make the request and the width is landscape width, but the position is portrait top - the result is the banner off to the left.
Seems to apply to the non-smart banners too. The advert is off-center i.e. centered as if it was in landscape.
I have added an ongui Input.deviceOrientation and this is reporting the physical orientation of the device, not the graphical orientation.
If I could force admob to make a portrait request then I don't think there would an issue.
It seems strange that admob knows where the top is (My portrait banner is always at the top of the portrait screen - i.e. graphically orientated) but doesn't seem to know the width (width is coming from physical orientation).

Hope I am explaining this so it makes sense...

I can add the unity project files to my drop box if this will help (but it will basically be a copy of the admob hello world app, forced to portrait)

Ram Parameswaran (Mobile SDK Team)

unread,
Mar 18, 2015, 9:19:53 PM3/18/15
to google-adm...@googlegroups.com
I am able to replicate the problem you are having with smart banners but not with regular banners. I have attached a modified copy GADUBanner.m. It contains a single line change where the orientation is determined. Can you try replacing GADUBanner.m with the attached version in your iOS project.

- Ram
GADUBanner.m

BernieBresslaw

unread,
Mar 19, 2015, 9:17:50 AM3/19/15
to google-adm...@googlegroups.com
Thanks Ram, that seems to sort it.
Using the the whole file caused complaints with my build - missing top left definitions etc. but changing this line 

  UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];


to this...


  UIDeviceOrientation currentOrientation = [UIApplication sharedApplication].statusBarOrientation;


....fixed it.


Thanks for the help.


Dave (BernieBresslaw)

Ram Parameswaran (Mobile SDK Team)

unread,
Mar 19, 2015, 11:57:53 AM3/19/15
to google-adm...@googlegroups.com
Seems I modified a different version of GADUBanner but glad I could be of help. This change will be pushed out in a future release.

- Ram
Reply all
Reply to author
Forward
0 new messages