Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8: Admob banner ad implementation in "universal storyboard" (iPhone + iPhone 6 + iPad)

Apple introduced universal storyboard for developing one interface that works on all iPhone sizes and iPad sizes.

Can Admob banner ads support universal storyboard? iPhone 6 (plus)?

Admob Banner ad size, which is not currently showing sizes for iPhone 6 (plus).

Admob quick start guide, which used a fixed 320*50 frame size. How can I add support for iPad and 4.7"/5.5" displays?

Here's the universal storyboard guide from [Raywenderlich], or [Apple] ->I can't post the links due to lack of reputations :(

Thanks!

like image 492
FriedPotato Avatar asked Oct 11 '14 09:10

FriedPotato


2 Answers

There are two moments you should rely on:

  1. Its possible to use SmartBanners for every type of device (kGADAdSizeSmartBannerPortrait or kGADAdSizeSmartBannerLandscape). Banner with required size will be downloaded automatically (its a main pros of smart banners usage). As said in google docs:

In portrait mode on phones, this will make the ad view either 320x50 or 360x50 in size, depending on whether the device is widescreen. In landscape mode on phones, this will make the ad view anywhere from 480x32 to 682x32 depending on the height of the device.

When an image ad won't take up the entire allotted space for the banner, we'll center the image and use a hexagonal textile filler (see image) to fill up the remaining space. Note that AdSense backfill ads will be centered and have "transparent" filler.

so you shouldn't worry about that.

  1. If you are using size classes (and autolayout consequently) you could setup separate height constraints for iPads and iPhones (90 and 50 px respectively) in storyboard (easier) or dynamically in code, using bannerView.frame.size.height value (better and flexible)

To change a height value for a banner in Storyboard view you should:

  1. Add a 90 px height constraint for w:Any h:Any
  2. Switch to w:Compact h:Regular (to select all iPhones)
  3. Find a constraint, select it and press Cmd+Delete. That will disable constraint for current size class
  4. Add new 50 px constraint
like image 77
slxl Avatar answered Oct 22 '22 02:10

slxl


At this point in time, I don't think there's really a decent solution here. It's speculation on my part, but I think the real issue is that Google just doesn't yet have the correctly-sized creatives to serve up 6 and 6Plus ads.

That said, I'm using the following code, in the hopes that, in the future, the "kGADAdSizeSmartBannerPortrait" size will cause adMob to serve up content that's sized properly for the 6 and 6Plus. This code currently results in a 320x50 banner being served to my apps when running on the 6 and 6Plus. (Note also that my app is portrait-only, but it wouldn't be too much trouble to add landscape support to this.)

// Create adMob ad View (note the use of various macros to detect device)
if (isiPad) {
    _adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeFullBanner];
}
else if (isiPhone6) {
    _adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
}
else if (isiPhone6Plus) {
    _adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
}
else {
    // boring old iPhones and iPod touches
    _adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
}
like image 24
Steven W. Disbrow Avatar answered Oct 22 '22 02:10

Steven W. Disbrow