AATKit iOS Integration
Release Notes
  • Start
    • Setup
      • Minimum iOS Version
      • Cocoapods
      • Swift Package Manager
      • AATKit Reporting
      • App Transport Security (ATS)
      • SKAdNetwork
    • Initialization
    • Consent
      • General Handling
      • Managed Consent
        • Google CMP
        • Sourcepoint CMP
        • SFBX (AppConsent) CMP
      • Vendor Consent
      • Simple Consent
    • Plugins documentation
    • Additional Information
  • Formats
    • Introduction
    • Banner
      • Auto Load Banner
      • Multi-Size Auto Load Banner
      • Banner Cache
      • Infeed Banner
      • Asynchronous Infeed Banner
      • Sticky Banner
      • Multi-Size Banner
    • Fullscreen (Interstitial)
    • AppOpen (Google)
    • Rewarded Video
      • Server-Side Verification (SSV)
    • Native Ad
      • Basic Integration
      • Asynchronous Basic Integration
      • Network Specifics
        • Native Ads: Google
        • Native Ads: Applovin
  • Ad Networks
    • Customize Ad Networks
    • Privacy Requirements
    • Google Mobile Ads SDK
    • AppNexus Custom Interstitial Auto Dismiss Delay
    • FeedAd Banner Options
    • AmazonHB
  • Advanced
    • Targeting
      • Key-Value Targeting
      • User Targeting
      • Content Targeting URL
    • Frequency Capping
    • Advanced Delegates
      • Reports Delegate
      • Impression Delegate (ILRD)
      • Statistics Delegate
    • AATKit's Size
    • Ad Space and Fill Rate
    • Shake Debug
    • Publisher Provided ID
    • Child-directed Support
    • Disabling Ad Networks
    • Geo Tracking
    • Ad Quality
    • Creatives History
  • Other
    • AdMob Custom Events
    • Datonomy
    • Reference
      • Classes
        • AATConfiguration
        • AATRuntimeConfiguration
        • AATManagedConsent
        • AATVendorConsent
        • AATSimpleConsent
        • AATAdInfo
        • AATBannerConfiguration
        • AATBannerRequest
        • AATBannerCacheConfiguration
        • AATBannerAlign
        • AATPlacementHistoryInfo
        • AATReward
        • AATRewardedAdSSVInfo
        • AATNativeAdRating
        • AATImpression
        • AATPriceInfo
        • AATAdNetworksOptions
          • AATAppNexusOptions
          • AATFeedAdOptions
          • AATAdMobOptions
          • AATDFPOptions
          • AATDatonomyOptions
        • AATDebugInfo
        • AATDebugScreenConfiguration
        • AATUserTargeting
        • AATCollapsibleBannerOptions
      • Protocols
        • AATDelegate
        • AATManagedConsentDelegate
        • AATVendorConsentDelegate
        • AATPlacement
        • AATStickyBannerPlacement
        • AATStickyBannerPlacementDelegate
        • AATMultiSizeBannerPlacement
        • AATMultiSizeBannerPlacementDelegate
        • AATInfeedBannerPlacement
        • AATInfeedBannerPlacementDelegate
        • AATAsyncInfeedBannerPlacement
        • AATBannerRequestDelegate
        • AATBannerCache
        • AATBannerCacheDelegate
        • AATBannerCacheStatusDelegate
        • AATAutoLoadBannerPlacement
        • AATAutoLoadBannerPlacementDelegate
        • AATAutoLoadMultiSizeBannerPlacement
        • AATAutoLoadMultiSizeBannerPlacementDelegate
        • AATFullscreenPlacement
        • AATFullscreenPlacementDelegate
        • AATAppOpenAdPlacement
        • AATAppOpenPlacementDelegate
        • AATRewardedVideoPlacement
        • AATRewardedVideoPlacementDelegate
        • AATNativeAdPlacement
        • AATNativePlacementDelegate
        • AATAsyncNativeAdPlacement
        • AATNativeAdData
        • AATReportsDelegate
        • AATImpressionDelegate
        • AATStatisticsDelegate
      • Enumerations
        • AATAdNetwork
        • AATGender
        • AATLogLevel
        • AATManagedConsentState
        • NonIABConsent
        • AATBannerPlacementSize
        • AATBannerSize
        • HorizontalAlign
        • VerticalAlign
        • AATMediationType
        • AATImpressionPricePrecisionType
  • Samples
Powered by GitBook
On this page
  • Create Placement
  • Listen to Callbacks
  • Request Ad
  • Complete Code Example
  1. Formats
  2. Banner

Multi-Size Banner

Integrate Multi-Size Banners

Last updated 5 months ago

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

Create Placement

It will depend on the server-side configuration on the Dashboard and what actual sizes are getting delivered to your placement.

To create an instance of , use the following API:

var placement = AATSDK.createMultiSizeBannerPlacement(name: "<PLACEMENT_NAME>")
id<AATMultiSizeBannerPlacement> placement = [AATSDK createMultiSizeBannerPlacementWithName:@"<PLACEMENT_NAME>"];

The green background is an ad container (UIView), into which the placement view is added by the app. It represents the space that the app reserves for a multi-size banner placement view (the green colour is just used here for explanatory purposes).

Listen to Callbacks

placement.delegate = self
placement.delegate = self;

Request Ad

Automatic Reload

To automatically load (and reload) the sticky banner placement enable auto-reload. If you do not set the refresh time interval seconds explicitly, AATKit will

  • Reload every 30 seconds (if no refresh time interval is set on the Dashboard)

  • Respect the refresh time interval setting of the Dashboard (which means, you can configure the interval without having to re-publish your app)

// reload the banner placement every 30 seconds.
placement.startAutoReload()
// OR set refresh time manually
placement.startAutoReload(seconds: 45)
//reload the banner placement every 30 seconds.
[self.placement startAutoReload];
// or set refresh time manually
[self.placement startAutoReloadWithSeconds:45];

The minimum refresh time is 30 seconds.

This needs to stop the auto-reload when it is no longer needed (e.g. if the view controller presenting ads will disappear):

placement.stopAutoReload()
[self.placement stopAutoReload];

Manual Load

To manually load the sticky banner placement:

placement.reload()
// Or using force load
placement.reload(forceLoad: true)
[placement reload];
// Or using force load
[self.placement reloadWithForceLoad:YES];

Force Load

  • false (default): reload() will respect the current time interval.

  • true: reload() will immediately reload (irrespective of the fact when the last ad was loaded). This can be useful if the same sticky banner placement is used on various different pages of the app and you want to load a new ad every time the user navigates to another page (while still using auto-reloading).

Complete Code Example

class ViewController: UIViewController {
    // Create the placement
    var placement = AATSDK.createMultiSizeBannerPlacement(name: "<PLACEMENT_NAME>")
    var bannerAdView: UIView?
 
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        // [IMPORTANT] Notify AATKit about the currently active view controller
        AATSDK.controllerViewDidAppear(controller: self)
        
        // Set placement delegate to listen to the callbacks
        placement.delegate = self
        
        // reload the banner placement every 30 seconds.
        placement.startAutoReload()
        // OR set refresh time manually
        placement.startAutoReload(seconds: 30)
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        // [IMPORTANT] Remove the currently active view controller
        AATSDK.controllerViewWillDisappear()
        // [IMPORTANT] Stop placement auto-reload
        placement?.stopAutoReload()
    }
}

extension ViewController: AATMultiSizeBannerPlacementDelegate {
    func aatHaveAdWithBannerView(placement: AATPlacement, bannerView: AATBannerPlacementWrapperView) {
        // The placement has loaded a new ad
        // [IMPORTANT] remove the previously displayed banner view
        bannerAdView?.removeFromSuperview()
        bannerAdView = bannerView
        view.addSubview(bannerAdView)
        // Change bannerView frame (or constraints) to the desired location on the screen
    }

    func aatNoAd(placement: AATPlacement) {
        // The placement could not load a new ad
    }
    
    func aatPauseForAd(placement: AATPlacement) {
        // Ad has been displayed on the screen
    }

    func aatResumeAfterAd(placement: AATPlacement) {
        // Back to the app after clicking on the ad
    }
}
@interface ViewController () <AATMultiSizeBannerPlacementDelegate>
@property id<AATMultiSizeBannerPlacement> placement;
@property UIView *bannerAdView;
@end

@implementation ViewController
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    // [IMPORTANT] Notify AATKit about the currently active view controller
    [AATSDK controllerViewDidAppearWithController:self];
    
    // Create the placement
    self.placement = [AATSDK createMultiSizeBannerPlacementWithName:@"<PLACEMENT_NAME>"];
    
    // Set placement delegate to listen to the callbacks
    self.placement.delegate = self;
    
    //reload the banner placement every 30 seconds.
    [self.placement startAutoReload];
    // or set refresh time manually
    [self.placement startAutoReloadWithSeconds:30];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    // [IMPORTANT] Remove the currently active view controller
    [AATSDK controllerViewWillDisappear];
    // [IMPORTANT] Stop placement autoreload
    [self.placement stopAutoReload];
}

#pragma mark - AATMultiSizeBannerPlacementDelegate
- (void)aatHaveAdWithBannerViewWithPlacement:(id<AATPlacement> _Nonnull)placement bannerView:(AATBannerPlacementWrapperView * _Nonnull)bannerView {
    // The placement has loaded a new ad
    // [IMPORTANT] remove the previously displayed banner view
    [self.bannerAdView removeFromSuperview];
    self.bannerAdView = bannerView;
    [self.view addSubview:self.bannerAdView];
    // Change bannerAdView frame (or constraints) to the desired location on the screen
}

- (void)aatNoAdWithPlacement:(id<AATPlacement> _Nonnull)placement {
    // The placement could not load a new ad
}

- (void)aatPauseForAdWithPlacement:(id<AATPlacement> _Nonnull)placement {
    // Ad has been displayed on the screen
}

- (void)aatResumeAfterAdWithPlacement:(id<AATPlacement> _Nonnull)placement { 
    // Back to the app after clicking on the ad
}
@end

Through the use of , you can listen to the different placement callbacks.

AATMultiSizeBannerPlacementDelegate
sticky banners
AATMultiSizeBannerPlacement