Autoload banner placement is a new type of banner placements 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.
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.
iflet 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 screenplacement.startAutoReload()
classViewController:UIViewController {// Create the placementlazyvar placement = AATSDK.createAutoLoadBannerPlacement(name:"<PLACEMENT_NAME>", size: .banner320x50)overridefuncviewDidAppear(_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 viewiflet 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() }overridefuncviewWillDisappear(_animated: Bool) { super.viewWillDisappear(animated)// [IMPORTANT] Remove the currently active view controller AATSDK.controllerViewWillDisappear()// [IMPORTANT] Stop placement auto-reload placement?.stopAutoReload() }}extensionViewController:AATAutoLoadBannerPlacementDelegate {funcaatHaveAd(placement: AATPlacement) {// The placement has loaded a new ad }funcaatNoAd(placement: AATPlacement) {// The placement could not load a new ad }funcaatPauseForAd(placement: AATPlacement) {// The placement has displayed an ad }funcaatResumeAfterAd(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