Wiki

Clone wiki

Fullscreen and RV Sample / Fullscreen migration to AATKit 3 migration

Fullscreen migration to AATKit 3 migration (beta)

Creating Fullscreen Placement

to create a Fullscreen placement call the following:

Instead of:

Swift

let fullscreenPlacement = AATKit.createPlacement(withName: "interstitial", andType: .fullscreen)
Objective-C:
id fullscreenPlacement = [AATKit createPlacementWithName:@"interstitial" andType:AATKitFullscreen];

Use:

Swift

let fullscreenPlacement = AATSDK.createFullscreenPlacement(name: "Fullscreen")
Objective-C:
id fullscreenPlacement = [AATSDK createFullscreenPlacementWithName:@"Fullscreen"];
You have to specify a placement name, which allows for referencing the placement later on. Also, the type argument specifies the size of the ad to be displayed.

Note placement instance is supposed to be reused. Do not create a placement instance for each fullscreen ad you want to display. Each location where fullscreen ads should be displayed can be handled by a single placement instance.

Request Ad

You can request ads for the fullscreen placement either automatically or manually. We strongly recommend using the auto-reload for fullscreen ads, because a fullscreen should be ready to present when the app triggers its presentation.

Automatic Reload

Note: The fullscreen placement fires aatHaveAd(:) delegate method only once per loaded ad. So, Before starting the auto-reload, you should check for ads from the previous load/auto-reload using the placement has ad API.

Instead of:

Objective-C:

// Start fullscreen placement auto-reloading to automatically
// download new fullscreen ad after presenting the current one.
[AATKit startPlacementAutoReload:self.fullscreenPlacement];
Swift:
// Start fullscreen placement auto-reloading to automatically
// download new fullscreen ad after presenting the current one.
AATKit.startPlacementAutoReload(fullscreenPlacement)

Use:

Objective-C:

// Start fullscreen placement auto-reloading to automatically
// download new fullscreen ad after presenting the current one.
[self.fullscreenPlacement startAutoReload];
Swift:
// Start fullscreen placement auto-reloading to automatically
// download new fullscreen ad after presenting the current one.
fullscreenPlacement.startAutoReload()

In this scenario, a fullscreen Ad is loaded automatically. It is reloaded only if a previous fullscreen Ad has already been displayed.

Manual Load

To manually load a fullscreen Ad, the following method can be used:

Instead of:

Objective-C:

[AATKit reloadPlacement:fullscreenPlacement];
Swift:
AATKit.reload(fullscreenPlacement)
Use:

Objective-C:

[self.fullscreenPlacement reload];
Swift:
fullscreenPlacement?.reload()

Displaying a fullscreen Ad

Displaying a fullscreen Ad can be done in two ways.

First, the AATKit can be told to display a fullscreen placement using the following method:

Instead of:

Objective-C:

[AATKit showPlacement:fullscreenPlacement];
Swift:
AATKit.show(fullscreenPlacement)

Use:

Objective-C:

[self.fullscreenPlacement show];
Swift:
fullscreenPlacement.show()

The method will return a bool value indicating whether the fullscreen placement could be displayed or not. This means whether the fullscreen placement could be filled with an Ad by an Ad network.

Listening to Events

To register for the placement events, set the delegate property on AATFullscreenPlacement to an object that implements the AATFullscreenPlacementDelegate protocol.

Objective-C:

[self.placement setDelegate:self];

Swift:

placement.delegate = self

Implementing AATFullscreenPlacementDelegate

    func aatHaveAd() {
        /// This method will be called when there is an ad
    }

    func aatNoAd() {
        /// This method will be called when there is no ad available
    }

    func aatAdCurrentlyDisplayed() {
        /// This method will be called with the ad display event
    }

    func aatResumeAfterAd() {
        /// This method will be called when the app resumes after displaying an ad
    }

Assign a specific view controller to a placement

Setting a view controller during initialization of the AATKit, or by using the method + (void) setViewController:(nullable UIViewController*)con; sets a global view controller used by all placements.

It's also possible to assign a placement specific view controller, by using the following method:

Instead of:

Objective-C:

[AATKit setPlacementViewController:self forPlacement:fullscreenPlacement];
Swift:
#!swift
[AATKit setPlacementViewController:self forPlacement:fullscreenPlacement];

Use:

Objective-C:

[AATSDK controllerViewDidAppearWithController:self];

Swift:

#!swift
AATSDK.controllerViewDidAppear(controller: self)

In the ViewController's viewWillDisappear method, you should do the following:

Objective-C:

[AATSDK controllerViewWillDisappear];

Swift:

#!swift

AATSDK.controllerViewWillDisappear()

Has Ad

The fullscreen placement provides an API to check if it has a loaded ad.

Objective-C:

BOOL hasAd = [self.placement hasAd];
Swift:
let hasAd = placement.hasAd()

Listening to statistics events

AATStatisticsDelegate is an optional delegate you can implement if you need to get notified about statistics events. and pass it to placement while creating it using this Use:

placement.statisticsDelegate = self
for more info about it please refer to AATStatisticsDelegate Guide

SampleApp

Updated