Auto Load banner placement is our most recent implementation of a banner that 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 depending on the Refresh Rate placement setting on Gravite dashboard.
You have to specify a placement name and the size argument of the type AATBannerPlacementSize which specifies the size of the ad to be displayed.
Determine the Appropriate Banner Size
To ensure you choose the best banner size for a device, use the following API to determine whether the device is a tablet or not. This information will help you select the optimal banner size for the device type.
The autoload 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. The placement will update the view content every time 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 autoload banner placement automatically.
If you do not set the refresh time interval seconds on the dashboard, AATKit will:
Reload every 30 seconds.
respect the refresh time interval setting of the Dashboard (which means, you can configure the interval without having to re-publish your app).
Note: 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()
//reload the banner placement each 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.createAutoLoadBannerPlacement(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
// 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()
}
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: AATAutoLoadBannerPlacementDelegate {
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) {
// The placement has displayed an ad
}
func aatResumeAfterAd(placement: AATPlacement) {
// Back to the app after clicking on the ad
}
}
@interface ViewController () <AATAutoLoadBannerPlacementDelegate>
@property id<AATAutoLoadBannerPlacement> 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 createAutoLoadBannerPlacementWithName:@"<PLACEMENT_NAME>" size:AATBannerPlacementSizeBanner300x50];
// Set placement delegate to listen to the callbacks
self.placement.delegate = self;
// 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];
}
- (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 - AATAutoLoadBannerPlacementDelegate
- (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>)placement {
// The placement has displayed an ad
}
- (void)aatResumeAfterAdWithPlacement:(id<AATPlacement>)placement {
// Back to the app after clicking on the ad
}
@end