Get Started with Avocarrot

Overview

Examples

Android

Overview

- Native Ads

List/Feed

Custom

- Standard IAB Formats

Banner

Interstitial

Video

- Others

Troubleshooting

Admob Android Adapter

Mopub Android Adapter

DFP Android Adapter

iOS

Overview

- Native Ads

List/Feed

Custom

- Standard IAB Formats

Banner

Interstitial

Video

- Others

Troubleshooting

- Adapters

Admob iOS Adapter

Mopub iOS Adapter

DFP iOS Adapter

API Documentation

Reporting API

Help

Supported Networks & Ad Types

General

Earnings

Payments and Accounting

Integration

Reporting

Mediation Network Optimization

Legal and Privacy

Updates

SDK Change Log

Android Change Log

iOS Change Log

List/Feed

Updated 4 days ago ​by Derek Lim

Overview

This tutorial helps you setup List/Feed ads and receive your first Avocarrot Native ad.


Prerequisites

Create a  List/Feed ad unit from your app on Avocarrot Dashboard 

Requirements & Dependencies

  • Target iOS 8.0 or higher

Setup SDK

Avocarrot iOS SDK supports iOS 8.0 or higher.

You can add AvocarrotSDK to your project using Cocoapods  (recommended) or manually

Note: If you don’t have pods in your project, set them up using the Getting Started guide
  1. Add pod ‘avocarrot-ios-sdk/Core’ to your Podfile to integrate it to your project
  2. Add the ad types you require to your Podfile:
    pod ‘avocarrot-ios-sdk/NativeView’

We also have sample code available at our GitHub repository.

Manual Avocarrot SDK integration guide

  1. Add the following SDK files to your project (required)
    Ad type Frameworks
    Native view (rendered native ad) AvocarrotCore.framework, AvocarrotNativeAssets.framework, AvocarrotNativeView.framework, Vast.framework
  2. Add -ObjC flag to project settings (Other Linker Flags property)  

    Note: If your app can’t use -ObjC flag just add -force_load $(PROJECT_DIR)/Pods/avocarrot-ios-sdk/AvocarrotSDK.framework/Versions/Current/AvocarrotSDK flag to Other Linker Flags

  3. Required system libraries for all libs

    The SDK with adapters uses the following system frameworks and libraries. You can set flag “Link Frameworks automatically” to YES otherwise you should add following system frameworks and libraries to your project manually:

    WebKit

    Security

    QuickLook

    MobileCoreServices

    CoreText

    AssetsLibrary

    Foundation

    CoreData

    Social

    MessageUI

    MediaPlayer

    EventKit

    EventKitUI

    QuartzCore

    CoreMedia

    CFNetwork

    SystemConfiguration

    CoreGraphics

    StoreKit

    CoreTelephony

    AVFoundation

    AdSupport

    AudioToolbox

    UIKit

    libxml2

    libsqlite3

    libz

Warning: Some Xcode versions support new settings only after the Xcode reboot. This also cleans the Xcode cache and remedies other problems.

TO DO list if you have a linking problem:

  • Clean Build
  • Restart Xcode
  • Delete your DerivedData folder in ~/Library/Developer/Xcode/DerivedData
  • Restart the computer

ATS settings in iOS 9.0 and greater

Since the Avocarrot SDK uses 3rd party networks to load ads and we have no control over these networks loading their content via https, you should disable ATS for your application to ensure the Avocarrot SDK behaves as intended. To disable ATS add the following settings to your application Info.plist file:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key><true/>
    <key>NSAllowsArbitraryLoadsForMedia</key><true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key><true/>
</dict>

Setup List/Feed Ads

  1. Configure In-Feed ViewerID of advertising space (like for native ad): 



    Stream adapter is a smart technology to add native ads as items in your feeds based on UITableView or UICollectionView. Settings for stream adapter are returned from the server side and you can change it as you wish.

    #import <Avocarrotnativeview/Avocarrotnativeview.h>
    ...
    self.adapter = [AvocarrotSDK.sharedSDK createStreamAdapterForTableView:self.tableView
                                                       parentViewController:self
                                                                   adUnitId:@"YOUR_NATIVE_AD_UNIT_ID"
                                                               templateType:AVONativeAdsTemplateTypeList
                                                                   delegate:sizeDelegate
                                                          templateCustomization:nil];
    self.adapter = [AvocarrotSDK.sharedSDK createStreamAdapterForCollectionView:self.collectionView
                                                            parentViewController:self
                                                                        adUnitId:@"YOUR_NATIVE_AD_UNIT_ID"
                                                                    templateType:AVONativeAdsTemplateTypeList
                                                                        delegate:sizeDelegate
                                                           templateCustomization:nil];
    
    import AvocarrotNativeView
    ...
    adapter = AvocarrotSDK.shared.createStreamAdapter(for: tableView,
                    parentViewController: self,
                    adUnitId: "YOUR_NATIVE_AD_UNIT_ID",
                    templateType: .list,
                    delegate: sizeDelegate,
                    templateCustomization: nil)
    adapter = AvocarrotSDK.shared.createStreamAdapter(for: collectionView,
                    parentViewController: self,
                    adUnitId: "YOUR_NATIVE_AD_UNIT_ID",
                    templateType: .list,
                    delegate: sizeDelegate,
                    templateCustomization: nil)
    
  2. Note for custom collection view layout:  If you want to know the original index path of a cell in your feed without ads use this method (it may be important to load data from your data array):

    - (NSIndexPath * _Nullable)originalIndexPath:(NSIndexPath * _Nonnull)indexPath;

    If you want to use methods of UITableView and UICollectionView which work with NSIndexPath please use UITableView (AVOStreamAdapter) and UICollectionView (AVOStreamAdapter) categories (declared in AVOTableViewStreamAdapter.h and AVOCollectionViewStreamAdapter.h). There categories contain methods with avo_ prefix which return original indexPaths.

    To process stream adapter events, you should implement blocks or subscribe to notifications. The following is available:

    MethodDescriptionNSNotificationCenter key
    - (instancetype _Nonnull)onAdsDidLoad:(nullable void (^)(void))blockCalled after ads for stream adapter have been loaded. After this event you can reload your UITableView/UICollectionView or could wait - ads will be added automatically during scrolling.kAVONotification_StreamAdapterAdsDidLoad
    - (instancetype _Nonnull)onAdsFailed:(nullable void (^)(void))blockCalled after ads for stream adapter failed to load.kAVONotification_StreamAdapterAdsFailed
    Currently stream adapter does not support dynamic modification of data source (insert, move, delete of items). This support will be added soon.

    Don’t forget to retain List/Feed adapter by using your local variable

  3. Congratulations! Compile and Run your project . You can now customize your List/Feed  ads to match the look and feel of your app.

Mediation

If you want you can enable the mediation feature of Avocarrot and receive ads from 3rd party providers. You can follow the bellow steps to start mediating demand partners through Avocarrot.
If you’re already integrated with a demand buyer,  It is not mandatory to remove all SDKs, but we would recommend it in order to ensure a seamless and coherent integration with Avocarrot.
  1. Ensure pod ‘avocarrot-ios-sdk/Core’ is added to your Podfile to integrate it to your project
  2. Ensure the following line has been added:
    pod 'avocarrot-ios-sdk/NativeView'
    
  3. To add networks individually, add only the corresponding lines for each network

    NetworkLine
    Admobpod 'avocarrot-ios-sdk/NativeViewAdapters/GoogleMobileAdsAdapter'
    Facebookpod 'avocarrot-ios-sdk/NativeViewAdapters/FBAudienceAdapter'
    Mopubpod 'avocarrot-ios-sdk/NativeViewAdapters/MopubAdapter'
    Applovinpod 'avocarrot-ios-sdk/NativeViewAdapters/AppLovinAdapter'
    InLocopod 'avocarrot-ios-sdk/NativeViewAdapters/InLocoAdapter'
  4. To add all networks available use the following line: (Optional)
    pod 'avocarrot-ios-sdk/NativeViewAdapters'

We also have sample code available at our GitHub repository.

Manual Avocarrot SDK integration guide

  1. Check that the following frameworks are added into your project:
    Ad type Frameworks
    Native view (rendered native ad) AvocarrotCore.framework, AvocarrotNativeAssets.framework, AvocarrotNativeView.framework, Vast.framework
  2. To show native ads from client-side mediated networks in your application you need to add:
  3. For each added external ad network from the section above you should add the SDK adapter for this network for each ad type from the Adapters folder. Just add the necessary adapters to the project. 
    NetworkAdapters
    AdmoblibAVOGoogleMobileAdsAdapter-Core.alibAVOGoogleMobileAdsAdapter-Native.a
    Facebook AudiencelibAVOFBAudienceAdapter-Core.alibAVOFBAudienceAdapter-Native.a
    MopublibAVOMopubAdapter-Core.alibAVOMopubAdapter-Native.a
    ApplovinlibAVOAppLovinAdapter-Core.alibAVOAppLovinAdapter-Native.a
    BaidulibAVOBaiduAdapter-Core.alibAVOBaiduAdapter-Native.a
    TencentlibAVOTencentAdapter-Native.a
    InLocolibAVOInLocoAdapter-Core.alibAVOInLocoAdapter-Native.a

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 your 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?