Native
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.
Unlike the other formats, the app provides the layout and the SDK fills it with the assets of the ad, no matter which demand source has filled it.
Ad view
Section titled “Ad view”The first step is to create the view that will be used to display the ads. It has to be a WANativeAdView, or a subclass of it, where every asset that the app wants to show is connected to the corresponding outlet.
The easiest way is to create a XIB file, set WANativeAdView as the class of its root view and connect the outlets from the Interface Builder:
| Outlet | Type | Description |
|---|---|---|
advertiserLabel | UILabel | Name of the advertiser |
bodyLabel | UILabel | Description of the ad |
callToActionButton | UIButton | Button that invites the user to interact |
headlineLabel | UILabel | Headline of the ad |
iconImageView | UIImageView | Icon of the ad |
mediaContainer | UIView | Container for the media content (image or video) |
optionsContainer | UIView | Container for the options view of the ad |
priceLabel | UILabel | Price of the promoted product |
ratingContainer | UIView | Container for the rating of the promoted product |
storeLabel | UILabel | Store of the promoted product |
Every outlet is optional, so you only need to connect the assets that your design displays.
Integration
Section titled “Integration”To request a native ad, you need to make an integration by code as shown in the example below:
import UIKitimport WortiseSDK
class ViewController: UIViewController {
private var nativeAd: WANativeAd?
private var nativeAdLoader: WANativeAdLoader?
private var nativeAdView: WANativeAdView?
override func viewDidLoad() { super.viewDidLoad() ... let loader = WANativeAdLoader( adUnitId: "Wortise Ad Unit ID", delegate: self )
loader.rootViewController = self
nativeAdLoader = loader
loader.loadAd() }
deinit { nativeAd?.destroy() nativeAdLoader?.destroy() }}
extension ViewController: WANativeDelegate {
func didLoad(nativeAd: WANativeAd) { // Invoked when the ad has been loaded self.nativeAd?.destroy() self.nativeAd = nativeAd
// Instantiate the ad view and add it to the interface let adView = Bundle.main.loadNibNamed( "NativeAdView", owner: nil )?.first as! WANativeAdView
view.addSubview(adView)
nativeAdView = adView
nativeAdLoader?.render(ad: nativeAd, into: adView) }
func didClick(nativeAd: WANativeAd) { // Invoked when the ad has been clicked }
func didFailToLoad(nativeAd error: WAAdError) { // Invoked when the ad could not be loaded // (because of an error or no fill) }
func didImpress(nativeAd: WANativeAd) { // Invoked when the ad has generated an impression }
func didPayRevenue(nativeAd: WANativeAd, data: WARevenueData) { // Invoked when the ad has generated revenue }}The render(ad:into:) method fills the outlets of the view with the assets of the ad and registers them to track the clicks and the impressions. It returns false when the ad could not be rendered.
Ad assets
Section titled “Ad assets”The WANativeAd class exposes the assets of the ad, which can be used to customise the view before rendering it:
| Property | Type | Description |
|---|---|---|
advertiser | String? | Name of the advertiser |
body | String? | Description of the ad |
callToAction | String? | Text of the call to action |
headline | String? | Headline of the ad |
icon | Image? | Icon of the ad |
images | [Image] | Images of the ad |
mediaContent | MediaContent? | Media content of the ad (image or video) |
price | String? | Price of the promoted product |
rating | Double? | Rating of the promoted product |
store | String? | Store of the promoted product |
Request parameters
Section titled “Request parameters”The loadAd method also accepts a WARequestParameters instance, in the same way as the rest of the formats:
nativeAdLoader?.loadAd(parameters: WARequestParameters(agent: "your agent"))Migration from WAGoogleNativeAd
Section titled “Migration from WAGoogleNativeAd”If your app already integrated the deprecated WAGoogleNativeAd class, these are the equivalences with the new integration:
| Deprecated | Replacement |
|---|---|
WAGoogleNativeAd(adUnitId:delegate:) | WANativeAdLoader(adUnitId:delegate:) |
WAGoogleNativeDelegate | WANativeDelegate |
load() | loadAd() (or loadAd(parameters:)) |
didLoad(nativeAd:googleNativeAd:) | didLoad(nativeAd:) — a WANativeAd, no Google type |
didFailToLoad(nativeAd:error:) | didFailToLoad(nativeAd:) |
didRecord(impression:) | didImpress(nativeAd:) |
options ([GADAdLoaderOptions]) | removed — the SDK configures the request |
Your own GADNativeAdView and asset wiring | WANativeAdView outlets + render(ad:into:) |
In practice, the changes are:
- Drop the Google types. There is no
NativeAdfrom Google in the callbacks anymore, so the app no longer importsGoogleMobileAdsfor native ads. - Replace the class of the view. The root view of the layout becomes a
WANativeAdView, connecting the outlets from the Ad view section instead of Google’s asset views. - Render through the loader. Where the app used to configure a
GADNativeAdViewin the load callback, now it callsrender(ad:into:). - Media view. Remove the
GADMediaViewfrom the layout and connect a plainUIViewasmediaContainer; the SDK inserts the right media view for whichever network filled the ad.
Before
Section titled “Before”func didLoad(nativeAd: WAGoogleNativeAd, googleNativeAd: NativeAd) { let adView = // your GADNativeAdView
adView.headlineView = headlineLabel adView.callToActionView = callToActionButton adView.mediaView = mediaView // ... one line per asset ...
adView.nativeAd = googleNativeAd}func didLoad(nativeAd: WANativeAd) { nativeAdLoader?.render(ad: nativeAd, into: adView)}Legacy integration
Section titled “Legacy integration”Apps that still use WAGoogleNativeAd receive Google’s NativeAd instance in the didLoad(nativeAd:googleNativeAd:) callback, and are responsible for building the GADNativeAdView and registering every asset, as described in Google’s documentation.
© 2026 Wortise. All rights reserved.