Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

iPhoneX admob ad offset?
Started by d.mach Sep 25 2018 12:01 PM

10 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 756 posts
  • Corona SDK

I have a game in the stores and got some feedback with new iPhones where players have this problem:

admob ads seem to have an offset (about 50px from the device border) and blocking the view on some GUI elements in the game.

 

Is this a known issue?

 

I first thought it is something in my code but can't find something wrong (until now). Will continue looking into it but have to ask if this is something happening elsewhere right now?

 

Thanks for your help!

 



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,363 posts
  • Corona SDK

Show us the code (from your game) where you display the banner, so we can help.

 

i.e. How exactly are you calling admob.show() (https://docs.coronalabs.com/plugin/admob/show.html) ?



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,970 posts
  • Corona Staff

The AdMob ad plugin already understands safe zone offsets. You don't need to do anything extra, however, your app has to also understand safe zone offsets and position UI elements properly.

 

In addition to what @roaminggamer is asking, can you also post a screenshot? But as I'm typing that question, I realized you might not have an iPhone X to test with. You should be able to test on the Xcode Simulator while simulating an iPhone X. You can also put up your app up on test flight and ask for iPhone X owners to test for you. Now that there are three new iPhone X models out and people are upgrading you should be able to find more people who can help you test.

 

Rob



[TOPIC: post.html]
#4

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 756 posts
  • Corona SDK

Thank you for your fast reply and help! I do nothing special in the code and call the admob banner without any extra positions.

It reads like it is admob detecting the device and a safe area to show the ad while the app is not because it is not looking for the next generation of Apple devices. So I think I have to test it like Rob is saying.

Are there any infos on how big the offset of the banner is? Can I look into the value via code?

Is it possible to turn the admob auto offset off somehow and do things manually?

 

Thanks for your help!



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,970 posts
  • Corona Staff

We have API's in the display.* family that gets you the proper safe zone offsets.  See:

 

http://docs.coronalabs.com/api/library/display/safeActualContentWidth.html

http://docs.coronalabs.com/api/library/display/safeActualContentHeight.html

http://docs.coronalabs.com/api/library/display/safeScreenOriginX.html

http://docs.coronalabs.com/api/library/display/safeScreenOriginY.html

http://docs.coronalabs.com/api/library/display/getSafeAreaInsets.html

 

You can do something like:

local safeBottom = display.safeActualContentHeight + display.safeScreenOriginY
local bannerHeight = 50 -- advertising buerau standard mobile banner height on phones

tabBar.y = safeBottom - bannerHeight - tabBar.height / 2

untested of course.

 

Finally, the AdMob's .show() method lets you set a "y" value that either can be something simple like "top" or "bottom" or a number to positioning anywhere on the screen.

 

Rob



[TOPIC: post.html]
#6

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 756 posts
  • Corona SDK

Thank you very much for the details and help!

 

One more question: How can I test admob on the iPhoneX simulator (Xcode)? I currently got a runtime error, because this doesn't seem to work with the plugin in the emulator.



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,970 posts
  • Corona Staff

Can you post your build.settings?



[TOPIC: post.html]
#8

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 756 posts
  • Corona SDK

I now have a device to test, so no need for the simulator anymore.

 

But I have one more question regarding the safe zone offsets: How do I check when to use them?

It looks like they also are used on older iPhones which don't need the offset for example. So how do I check if a device is needing a safe zone?



[TOPIC: post.html]
#9

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,363 posts
  • Corona SDK

https://docs.coronalabs.com/api/library/display/getSafeAreaInsets.html



[TOPIC: post.html]
#10

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 756 posts
  • Corona SDK

 

I then have to look into it a little bit more. I had offsets (in the simulator) for an iPhone5... but there shouldn't be any, right?



[TOPIC: post.html]
#11

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,970 posts
  • Corona Staff

If you are on a device that doesn't have any notch like features, display.safeActualContentHeight and display.actualyContentHeight should be the same. 

 

Also, display.safeScreenOriginY and display.screenOriginY should be the same (as well as the Width and X variants of the API calls).

 

Where there may be a difference, I believe that the "safe" calls take status bars into consideration and you shouldn't be positioning UI elements under status bars anyway, so using the "safe" calls should work just fine on the iPhone 5, 6, 7 and 8 families.

 

Rob




[topic_controls]
[/topic_controls]