Banner¶
Integration¶
An ADvantage banner is a NSObject that displays HTML5 ads that respond to user interaction (touch, wipe, click and etc.).
To add a banner to your view it takes only a few lines of code:
- Create an new instance of ADvantage instance in your code (pass your license key, siteId and position to its constructor)
var banner: ADvantage?
.
.
.
banner = ADvantage(bannerWithLicenseKey: "...", siteId: "...", position: "...")
ADvantage *banner = [[ADvantage alloc] initBannerWithLicenseKey:@"..." SiteId:@"..." Position:@"..."];
Tip
We recommend to initialize ADvantage after your app have gone through it own initialization.
- Add the ADvantage instance to your content view
container.addSubview(banner.view)
//Add ADvantage view to your layout
[container addSubview:banner.view];
Tip
To avoid the screen to be cropped you can use auto-layout constraints to contain your banner inside the view of your choosing.
- Implement the delegation methods to be able to treat the different events from ADvantage (For more information please visit ADvantage events):
override func viewDidLoad() {
...
banner.delegate = self
}
// Important methods for the ADvantage lifecycle
func advantage(_ advantage: ADvantage, didLoad state: AVLoadedState) {
//Do something based on banner state
}
func advantage(_ advantage: ADvantage, didFailWithError error: String?)
//Do someting after it fails
}
- (void)viewDidLoad{
...
[banner setDelegate:controller];
}
// Important methods for the ADvantage lifecycle
- (void)advantage:(ADvantage *)advantage didLoad:(AVLoadedState)state {
//Do something based on banner state
}
- (void)advantage:(ADvantage *)advantage didFailWithError:(NSString *)error {
//Do someting after it fails
}
- Load and show the ad via your ADvantage instances requestAd() method.
banner.requestAd()
//Show banner...
[banner requestAd];
Tip
It is common practice to create those objects inside a UIViewController viewDidLoad method.
Transparency Consent Framework 2.0 (TCF 2.0)¶
We strongly recommend the use of a Consent Management Platform (CMP) compliant with TCF 2.0 if your audience on your website/app, in whole or in part, is located within the EU.
Click here for instructions on how to hand over TCF 2.0 Consent to ADvantage.