Wiki

Clone wiki

Banner Sample / Multi-size Banner (AATKit 2)

Multi-Size Banner Placement

Index:

Multi-Size banner placements can present banner of varying sizes. For instance it is possible to display a banner of the standard size 320x53, followed by a medium rect angle of size 300x250 within the same placement.

MSB_inApp_example.png

(Note: the green background is an ad container (UIView), into which the placement view is added. It represents the space that is reserved for a multi-size banner placement's view.)

Meta Information

The following sizes are supported for Multi-Size Banner.

  1. 300x250
  2. 320x53
  3. 320x75 (DFP only)
  4. 320x100 (DFP only)
  5. 320x150 (DFP only)
  6. 468x60
  7. 768x90

Please contact the AddApptr support via support@addapptr.com, in order to let us know which formats you would like to use in your app. The AddApptr team will setup the backend accordingly.

Creating a Multi-Size Banner

A Multi-Size Banner is created by calling the method:

#!objective-c

+ (nonnull id) createPlacementWithName:(nonnull NSString *) placementName andType:(AATKitAdType)type
providing a placement name and specifying the AATKitAdType to be AATKitBannerMultiSize.

This process is just the same as for the normal banner placement.

Example:

Objective-C:

#!objective-c
[AATKit createPlacementWithName:@"MultiSizeBanner" andType:AATKitBannerMultiSize];
Swift:
#!swift
AATKit.createPlacement(withName: "MultiSizeBanner", andType: .bannerMultiSize)

Requesting an Ad

A Multi-Size Banner supports manual and automatic reload. For manual reload:

#!objective-c
+ (bool) reloadPlacement:(nonnull id) placement;

For automatic reload:

#!objective-c
+ (void) startPlacementAutoReload:(nonnull id) placement;

Reacting on the Multi-Size Banner Callback

When a Multi-Size Banner is successfully loaded a new callback is invoked.

#!objective-c
- (void) AATKitHaveAdOnMultiSizeBanner:(nonnull id) placement withView:(nonnull UIView*) placementView;
There are multiple reasons why an additional callback is introduced. 1. Due to the varying size of a Multi-Size Banner's view, it's necessary to provide the new encompassing view each time a new ad is loaded. This new view, can exchange the old view via an animation, which requires both view's to exist during the animation phase. This requires the programmer to take ownership of the placementView provided via the callback. The AATKit is providing an autoreleased placementView instance. Also, since the AATKit has no ownership of any (potential) previous placementView, the programmer may keep the old instance around in case of a animation or alike.

Objective-C:

#!objective-c
- (void)AATKitHaveAdOnMultiSizeBanner:(id)placement withView:(UIView *)placementView
{
    UIView *oldAdView = self.currentlyShownAdView;
    self.currentlyShownAdView = multiSizeBannerView;
    ...
}
Swift:
#!swift
func aatKitHaveAd(onMultiSizeBanner placement: AATKitPlacement, with placementView: UIView) {
    let oldView = currentlyShownAdView
    currentlyShownAdView = placementView
    ...
}

For successfully loaded Multi-Size Banner ads the callback - (void) AATKitHaveAd:(nonnull id) placement; will not be invoked.

In case no ad could be loaded on a Multi-Size Banner placement, the callback - (void) AATKitNoAds:(nonnull id) placement; is invoked. For this case, no new callback has been introduced.

Displaying a Multi-Size Banner

In order to show a Multi-Size Banner, it's view has to be positioned on the screen, similar to regular banner placements. Since a new placement view is provided each time the Multi-Size Banner specific callback is invoked, a potential previous placement view has to be disposed by the programmer, and a new one has to be positioned. Since the UIView frame can change each time Multi-Size Banner callback is invoked the programmer has to adapt the space available according to the view's frame.

Sample App

Updated