Native Ads: Applovin
Integrate native ads (AppLovin)
To use Applovin’s native ads you need to do the following:
Native ad assets are required to be encapsulated within a parent view of a specific type MANativeAdView
.
The same view must be passed to AATKit via the AATNativeAdData
method: attachToView(_ :)
.
Assign unique tag IDs to the native ad assets' UIViews in the xib/storyboard. These IDs will be used in the next integration step.
Bind the subviews using the assigned tags using an instance of MANativeAdViewBinder
. AppLovin does not guarantee a network will return certain assets.
let adViewBinder = MANativeAdViewBinder(builderBlock: { builder in
builder.titleLabelTag = YOUR_TITLE_LABEL_TAG
builder.advertiserLabelTag = YOUT_ADVERTISER_LABEL_TAG
builder.bodyLabelTag = YOUR_BODY_LABLE_TAG
builder.iconImageViewTag = YOUR_ICON_IMAGE_VIEW_TAG
builder.mediaContentViewTag = YOUR_MEDIA_VIEW_CONTENT_VIEW_TAG
builder.callToActionButtonTag = YOUR_CALL_TO_ACTION_LABEL_TAG
})
appLovinContainerView.bindViews(with: adViewBinder)
MANativeAdViewBinder *adViewBinder = [[MANativeAdViewBinder alloc] initWithBuilderBlock:^(MANativeAdViewBinderBuilder * _Nonnull builder) {
builder.titleLabelTag = YOUR_TITLE_LABEL_TAG;
builder.advertiserLabelTag = YOUT_ADVERTISER_LABEL_TAG;
builder.bodyLabelTag = YOUR_BODY_LABLE_TAG;
builder.iconImageViewTag = YOUR_ICON_IMAGE_VIEW_TAG;
builder.mediaContentViewTag = YOUR_MEDIA_VIEW_CONTENT_VIEW_TAG;
builder.callToActionButtonTag = YOUR_CALL_TO_ACTION_LABEL_TAG;
}]
[self.appLovinContainerView bindViewsWithAdViewBinder:adViewBinder];
Next, call attachToView(:)
when you need to display the ad.
nativeAd.attachToView(appLovinContainerView,
mainImageView: adMainImageView,
iconView: adIconImageView,
ctaView: adCTALabel)
[self.nativeAd attachToView:self.appLovinContainerView
mainImageView:self.mainImageView
iconView:self.iconImageView
ctaView:self.ctaLabel];