Asynchronous Infeed Banner
Asynchronous Infeed banner placements wrap the Infeed banner placement providing the same functionality but supporting Swift Concurrency.
Create Placement
To create an instance of AATAsyncInfeedBannerPlacement, use the following API:
let configuration = AATBannerConfiguration()
let placement = AATSDK.createAsyncInfeedBannerPlacement(name: "<PLACEMENT_NAME>", configuration: configuration)
AATBannerConfiguration
See the infeed banner configuration documentation.
Listen to Callbacks (Optional)
See the infeed callbacks documentation.
Request Ad
The async infeed banner placement uses swift concurrency. To request a banner, use the AATBannerRequest default initializer that takes an instance implementing AATBannerRequestDelegate as a parameter.
Configure AATBannerRequest
See the infeed banner request configuration.
Perform Request
Task {
let request = AATBannerRequest(delegate: self)
guard let adView = await bannerPlacement?.requestAd(request: request) else {
return
}
// Display the adView
}
Complete Code Example
class ViewController: UIViewController {
// Create the placement
var placement: AATInfeedBannerPlacement?
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// [IMPORTANT] Notify AATKit about the currently active view controller
AATSDK.controllerViewDidAppear(controller: self)
let configuration = AATBannerConfiguration()
placement = AATSDK.createInfeedBannerPlacement(name: "<PLACEMENT_NAME>", configuration: configuration)
// Set placement delegate to listen to the callbacks
placement.delegate = self
// Create the banner request instance
let request = AATBannerRequest(delegate: self)
// Configure request banner sizes
request.setRequestBannerSizes(sizes: Set([.banner320x53, .banner300x250]))
// Configure request targeting information
request.contentTargetingUrl = "http://example.com/similar/content"
// Configure request content targeting URL
request.targetingInformation = ["key": ["value"]]
// Perform the request
Task {
let request = AATBannerRequest(delegate: self)
guard let adView = await bannerPlacement?.requestAd(request: request) else {
return
}
// Display the adView
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// [IMPORTANT] Remove the currently active view controller
AATSDK.controllerViewWillDisappear()
}
}
// MARK: AATInfeedBannerPlacementDelegate
extension ViewController: AATInfeedBannerPlacementDelegate {
func aatPauseForAd(placement: AATPlacement) {
// Ad has been displayed on the screen
}
func aatResumeAfterAd(placement: AATPlacement) {
// Back to the app after clicking on the ad
}
}
// MARK: AATBannerRequestDelegate
extension ViewController: AATBannerRequestDelegate {
func shouldUseTargeting(for request: AATBannerRequest, network: AATAdNetwork) -> Bool {
return true
}
}
Last updated