Skip to content

Banner

Banner ads are rectangular image or text ads that occupy a space inside the application layout. They stay on screen while the users interact with the app and can automatically refresh after a certain period of time. If you are new in mobile advertising, they are an excellent choice to start.

To integrate a banner, you need to add a WABannerAd class component to the app interface.

Then, an ad load should be requested as shown in the example below:

import UIKit
import WortiseSDK
class ViewController: UIViewController {
@IBOutlet
weak var bannerAd: WABannerAd!
override func viewDidLoad() {
super.viewDidLoad()
...
bannerAd.adUnitId = "Wortise Ad Unit ID"
bannerAd.adSize = WAAdSize.height50
bannerAd.rootViewController = self
// Optional: value in seconds to auto-refresh the ad
bannerAd.autoRefreshTime = 60.0
bannerAd.loadAd()
}
}

Adaptive banners are a new banner format where the size of the ads is adapted according to the device and the app user-interface, in order to maximize performance.

Currently there is support for two kind of adaptive banners:

This kind of banner is designed to replace the traditional 320x50 banners and be positioned at the top or bottom of the screen.

To use this format, the following code must be used to configure an adaptive size:

// You need to specify the banner width
let adSize = WAAdSize.getAnchoredAdaptiveBannerAdSize(width: width)
bannerAd.adSize = adSize

Alternatively, this other option can be implemented to let the SDK calculate the banner width, where the WABannerAd instance itself or the UIView that will contain it should be passed:

let adSize = WAAdSize.getAnchoredAdaptiveBannerAdSize(container: view)
bannerAd.adSize = adSize

This other kind of banner, in comparison to the anchored, is designed to have a variable height and be positioned inside a scrolling content.

In this case, the following code must be used to configure a proper adaptive size:

let maxHeight = 200
// You need to specify the banner width. The maximum height is an
// optional parameter
let adSize = WAAdSize.getInlineAdaptiveBannerAdSize(width: width,
maxHeight: maxHeight)
bannerAd.adSize = adSize

Alternatively, this other option can be implemented to let the SDK calculate the banner width, where the WABannerAd instance itself or the UIView that will contain it should be passed:

let maxHeight = 200
let adSize = AdSize.getInlineAdaptiveBannerAdSize(container: view,
maxHeight: maxHeight)
bannerAd.adSize = adSize

Collapsible banners are anchored banners that are initially shown as a larger overlay, with a button that collapses them to their declared size. They are meant to improve the performance of anchored banners without taking up more space permanently.

To request one, pass a WARequestParameters instance with the desired position to the loadAd method:

let parameters = WARequestParameters(collapsible: .bottom)
bannerAd.loadAd(parameters: parameters)

The position determines where the expanded ad is anchored, and it must match the position of the banner inside the app interface:

ValueDescription
.bottomThe banner is placed at the bottom of the screen
.topThe banner is placed at the top of the screen

A listener can be set to any WABannerAd instance to receive the events that happen during its lifecycle. For this, you need to implement the WABannerDelegate interface as shown in the example below:

extension ViewController : WABannerDelegate {
func didClick(bannerAd: WABannerAd) {
// Invoked when the ad has been clicked
}
func didFailToLoad(bannerAd: WABannerAd, error: WAAdError) {
// Invoked when the ad could not be loaded
// (because of an error or no fill)
}
func didImpress(bannerAd: WABannerAd) {
// Invoked when the ad has generated an impression
}
func didLoad(bannerAd: WABannerAd) {
// Invoked when the ad has been loaded
}
func didPayRevenue(bannerAd: WABannerAd, data: WARevenuedata) {
// Invoked when the ad has generated revenue
}
}

Once the interface is implemented, the delegate is assigned to the ad instance:

bannerAd.delegate = self