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 (Optional)
  • Get the Banner View
  • Request Ad
  • Banner Alignment
  • Complete Code Example
  1. Formats
  2. Banner

Sticky Banner

Integrate Sticky Banners

Last updated 5 months ago

A sticky banner placement serves as a container for banner ads. It is commonly used as a static, constantly shown, part of the app’s presentation. The ad content of the banner changes over time. To create a placement you need to specify its name and size.

Create Placement

To create an instance of , use the following API:

var placement = AATSDK.createStickyBannerPlacement(name: "<PLACEMENT_NAME>", size: .banner320x50)
id<AATStickyBannerPlacement> placement = [AATSDK createStickyBannerPlacementWithName:@"<PLACEMENT_NAME>" size:AATBannerPlacementSizeBanner300x50];

You have to specify a placement name and the size argument of the type which specifies the size of the ad to be displayed.

Listen to Callbacks (Optional)

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

placement.delegate = self
placement.delegate = self;

Get the Banner View

The sticky banner placement provides a banner ad view once and will keep responsible for refreshing the displayed ad content over time. So, once you’ve created the placement, get the ad container view via this method func getPlacementView() -> UIView? and display it on the screen. If auto-reloading is used, the placement will update the view content once it has got a new ad.

if let bannerAdView = placement.getPlacementView() {
    view.addSubview(bannerAdView)
    // Change the bannerAdView frame to your desired location on the screen
}
UIView *bannerAdView = [self.placement getPlacementView];
[self.view addSubview:bannerAdView];
// Change the bannerAdView frame to your desired location on the screen

Request Ad

You can load ads for the sticky banner placement either automatically (recommended) or manually.

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)

Note: if you make use of automatic reload, please make sure to disable (or not enable) automatic banner refresh at your ad networks of choice. Otherwise, the different auto reloads would interfere with each other.

// reload the banner placement every 30 seconds.
placement.startAutoReload()
// OR set refresh time manually
placement.startAutoReload(seconds: 45)
//reload the banner placement each 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).

Banner Alignment

let alignment = AATBannerAlign(horizontalAlign: .center, verticalAlign: .center)
placement.setBannerAlign(alignment: alignment)
AATBannerAlign *alignment = [[AATBannerAlign alloc] initWithHorizontalAlign:HorizontalAlignCenter verticalAlign:VerticalAlignCenter];
[self.placement setBannerAlignWithAlignment:alignment];

The above image is for a placement created with size 375x50 while the loaded ad is 320x50. The red background is the placement ad container after setting the alignment to AATBannerAlign(horizontalAlign: .trailing, verticalAlign: .center) (the red colour is just used here for explanatory purposes).

Complete Code Example

class ViewController: UIViewController {
    // Create the placement
    var placement = AATSDK.createStickyBannerPlacement(name: "<PLACEMENT_NAME>", size: .banner320x50)
 
    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
        
        // Set ad view alignment inside the placement view
        let alignment = AATBannerAlign(horizontalAlign: .center, verticalAlign: .center)
        placement.setBannerAlign(alignment: alignment)
        
        // Get the banner view
        if let bannerAdView = placement.getPlacementView() {
            view.addSubview(bannerAdView)
            // Change the bannerAdView frame to your desired location on the screen
        }
        
        // 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: AATStickyBannerPlacementDelegate {
    func aatHaveAd(placement: AATPlacement) {
        // The placement has loaded a new ad
    }

    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 () <AATStickyBannerPlacementDelegate>
@property id<AATStickyBannerPlacement> placement;
@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 createStickyBannerPlacementWithName:@"<PLACEMENT_NAME>" size:AATBannerPlacementSizeBanner300x50];
    
    // Set placement delegate to listen to the callbacks
    self.placement.delegate = self;
    
    // Set ad view alignment inside the placement view
    AATBannerAlign *alignment = [[AATBannerAlign alloc] initWithHorizontalAlign:HorizontalAlignCenter verticalAlign:VerticalAlignCenter];
    [self.placement setBannerAlignWithAlignment:alignment];
    
    // Get the banner view
    UIView *bannerAdView = [self.placement getPlacementView];
    [self.view addSubview:bannerAdView];
    // Change the bannerAdView frame to your desired location on the screen
    
    //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 - AATStickyBannerPlacementDelegate
- (void)aatHaveAdWithPlacement:(id<AATPlacement>)placement {
    // The placement has loaded a new ad
}

- (void)aatNoAdWithPlacement:(id<AATPlacement>)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>)placement {
    // Back to the app after clicking on the ad
}
@end

If the placement is created with a size larger than the banner ad size (), you can align the banner ad inside the placement view. To set the ad alignment, use the setBannerAlign(alignment: AATBannerAlign) API passing the proper that contains information about and alignments.

AATStickyBannerPlacement
AATBannerPlacementSize
AATStickyBannerPlacementDelegate
AATBannerAlign
horizontal
vertical
see placement creation
A 375x50 placement displaying a 320x50 banner ad