Multi-size autoload banner placements are similar to autoload banners, 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.
It will depend on the server-side configuration on the Dashboard and what actual sizes are getting delivered to your placement.
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).
To automatically load (and reload) the multi-size auto-load 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()
//reload the banner placement every 30 seconds.
[self.placement startAutoReload];
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];
One Placement for Multiple Screens
If the same 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, you can achieve that by calling stopAutoReload() in the first controller and then call startAutoReload() in the next controller. This will immediately load and present a banner ad.
placement.stopAutoReload()
// move to next screen
placement.startAutoReload()
class ViewController: UIViewController {
// Create the placement
lazy var placement = AATSDK.createAutoLoadMultiSizeBannerPlacement(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()
}
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) {
// The placement has displayed an ad
}
func aatResumeAfterAd(placement: AATPlacement) {
// Back to the app after clicking on the ad
}
}
@interface ViewController () <AATAutoLoadMultiSizeBannerPlacementDelegate>
@property id<AATAutoLoadMultiSizeBannerPlacement> 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 createAutoLoadMultiSizeBannerPlacementWithName:@"<PLACEMENT_NAME>"];
// Set placement delegate to listen to the callbacks
self.placement.delegate = self;
//reload the banner placement every 30 seconds.
[self.placement startAutoReload];
}
- (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 - AATAutoLoadMultiSizeBannerPlacementDelegate
- (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 {
// The placement has displayed an ad
}
- (void)aatResumeAfterAdWithPlacement:(id<AATPlacement> _Nonnull)placement {
// Back to the app after clicking on the ad
}
@end