The native ads are a kind of ad that can be shown using the same visual style like the rest of the app, which allows a natural and non-intrusive integration with the user interface.
Currently, Wortise provides the possibility of use the native ads from Google's ad platform ("Native Advanced"), in a simple and direct way.
Integration
To request a native ad, it is needed to make an integration by code just as shown in the example below:
import UIKit
import WortiseSDK
class ViewController: UIViewController {
private var nativeAd: WAGoogleNativeAd!
override func viewDidLoad() {
super.viewDidLoad()
...
nativeAd = WAGoogleNativeAd(adUnitId: "test-native",
rootViewController: self,
delegate: self)
nativeAd.loadAd()
}
override func willMove(toParent controller: UIViewController?) {
super.willMove(toParent: controller)
...
nativeAd.destroy()
}
}
extension ViewController: WAGoogleNativeDelegate {
func didClick(nativeAd: WAGoogleNativeAd) {
// Invoked when the ad has been clicked
}
func didFailToLoad(nativeAd: WAGoogleNativeAd, error: WAAdError) {
// Invoked when the ad could not be loaded
// (because of an error or no fill)
}
func didLoad(nativeAd: WAGoogleNativeAd, googleNativeAd: GADNativeAd) {
// Invoked when the ad has been loaded
}
func didRecord(impression: WAGoogleNativeAd) {
// Invoked when the ad has generated an impression
}
}
Specify options
The WAGoogleNativeAd class includes an attribute called options which allows to specify custom options by using the GADAdLoaderOptions class from Google. This attribute must be set before loading the ad.
Below you can check a brief usage example:
let adOptions = GADNativeAdViewAdOptions()
// Set the options through "adOptions"
googleNativeAd.options = adOptions
Once the native ad has been successfully loaded, obtaining as result a GADNativeAd instance, it is needed to complete the integration by following Google's documentation on this matter: