Get Started with Avocarrot





- Avocarrot Exchange SDK

Setup Exchange SDK


Native Assets

Exchange Troubleshooting

- Avocarrot Mediation SDK

Setup Mediation

Stream Ads Mediation

Native ads Mediation

Native Assets Mediation

Banner Mediation

Interstitial Mediation

Video Mediation

Supported Networks & Ad Types

Mediation Troubleshooting



- Avocarrot Exchange SDK

Setup SDK


Native Assets

Exchange Troubleshooting

- Avocarrot Mediation

Getting Started With Mediation

Stream Ads Mediation

Native Ads Mediation

Banner Ads Mediation

Interstitial Ads Mediation

Video Ads Mediation

Supported Networks & Ad Types

Mediation Troubleshooting

API Documentation

Reporting API




SDK Change Log

Android Change Log

iOS Change Log

Native Assets

Updated a month ago ​by Theocharis Kyriakidis


This tutorial helps you setup NativeAssets ads in your iOS app and receive your first Avocarrot NativeAssets ad.


You need an Avocarrot account to complete the tutorial. Create an account
You need to setup the Avocarrot SDK. Setup Avocarrot SDK

Setup NativeAssets Ads

ID of advertising space for testing (Native ad): "7f900c7d-7ce3-4190-8e93-310053e70ca2"

“The ID above is meant for testing purpose only, please replace it with the Ad unit Id of your placement from the dashboard .

Our native assets are raw ad data without any pre-defined wrapping UI. We only request the container of this data for event registration.
The layout for a native assets is configured by developers with the help of the Interface Builder (creating .xib file) or manual creation of UI controls in code.
Use the following methods in your UIViewController subclass:

func loadNativeAd(withAdUnitId adUnitId: String,
                  success: @escaping (AVONativeAssets) -> UIView?,
                  failure: ((AVOError) -> ()))?)
- (void)loadNativeAdWithAdUnitId:(NSString *_Nonnull)adUnitId
        success:(UIView * _Nullable (^ _Nonnull)(AVONativeAssets *_Nonnull nativeAd))success
        failure:(void (^ _Nullable)(AVOError *_Nonnull error))failure;

The following method performs asynchronous downloading: raw native data without downloading linked resources and requests a container view for this data.

There is a common algorithm to use when implementing a custom native ad:

  1. Create your own subclass of UIView with any name (MyNativeBannerView for example) which will be used as ad view container.
  2. Render the other controls such as labels, buttons and image views, in the ad view container.
  3. Call loadNativeAdWithAdUnitId: etc with the required parameters, where the adUnitId is your private advertising space ID. Success block will be called when the native ad is successfully downloaded.
    Method returns the raw data object AVONativeAssets and requests your ad container where the ad will be rendered (required for registration of clicks and impressions), you can register ad container for interaction late by using this method of AVONativeAssets:
    - (instancetype _Nonnull)registerViewForInteraction:(nonnull UIView *)view forClickableSubviews:(nullable NSArray<UIView *> *)subviews, failure will be called when the native ad download fails, and returns AVOError
  4. Show the ad container on the screen.

For example:

import AvocarrotNativeAssets
AvocarrotSDK.shared.loadNativeAd(withAdUnitId: "",
                 success: { [unowned self] (ad: AVONativeAssets) -> UIView? in
                        let containerView = CustomNativeView()
                            print("Left application")
                        }).registerView(forInteraction: containerView, forClickableSubviews: nil)
                        return containerView
                 }) { (error) in
                        print("Native ad loading error: \(error.localizedDescription)")
#import <AvocarrotNativeAssets/AvocarrotSDK+AVONativeAssets.h>
__weak typeof(self) weakSelf = self;
[AvocarrotSDK.sharedSDK loadNativeAdWithAdUnitId:self.unitID
                     success:^UIView * _Nonnull(AVONativeAssets * _Nonnull nativeAd) {
                            CustomNativeView *nativeView = [CustomNativeView new];
                            [nativeView fillWithNativeAd:nativeAd];
                            [[[[nativeAd onImpression:^{
                                NSLog(@"Ad Impressed");
                            }] onClick:^{
                                NSLog(@"Ad Clicked");
                            }] onLeftApplication:^{
                                NSLog(@"Left application");
                            }] registerViewForInteraction:nativeView forClickableSubviews:nil];
                            [weakSelf.view addSubview:nativeView];
                            return nativeView;
                     } failure:^(AVOError * _Nonnull error) {
                            NSLog(@"Native ad loading error: %@", [error localizedDescription]);

To process custom native ad events, you should implement blocks. The following is available:

- (instancetype _Nonnull)onImpression:(nullable void (^)(void))impressionCalled when ad impression has been counted.
- (instancetype _Nonnull)onClick:(nullable void (^)(void))clickCalled when ad click has been counted.
- (instancetype _Nonnull)onLeftApplication:(nullable void (^)(void))leftApplicationCalled when application has been left after click.

Advanced Customization

Go Live!

  1. Remove sandbox If you have received a sample ad then simply disable the Sandbox mode by including the following instruction in your code:
    AvocarrotSDK.testMode = NO
    You should disable Sandbox mode ONLY when you are done with the integration and you are ready to publish your app. It is against Avocarrot's policies to use live ads during development, and doing so could get your Avocarrot account banned.
  2. Publish app You are now ready to upload your app and start making money!Your app will be marked as live once a certain amount of requests has been reached (>100 requests per day). If you have submitted your app in the Google Play/ Apple Store and you can see live ads, then you have nothing to worry about. Just wait until the impressions threshold has been reached and the app will be shown as live in your dashboard as well.
  3. Update payment details  

    Login to your account and update your payment settings.

Was this article useful?