Get Started with Glispa Connect

Overview

Examples

Android

Overview

- Native Ads

List/Feed

Custom

- Standard IAB Formats

Banner

Interstitial

Video

- Others

GDPR

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

General

Earnings

Payments and Accounting

Integration

Reporting

Legal and Privacy

Updates

SDK Deprecation Schedule

SDK Change Log

Android Change Log

iOS Change Log

List/Feed

Updated 2 months ago by Derek Lim

Overview

This tutorial helps you setup Native List/Feed ads and receive your first Glispa Connect (formerly Avocarrot) Native ad.

Prerequisites

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

Requirements & Dependencies

  • Target iOS 8.0 or higher

Setup SDK

Glispa Connect iOS SDK supports iOS 8.0 or higher.

You can add Glispa Connect SDK 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 Glispa Connect 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 Glispa Connect 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 Glispa Connect 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). You can implement it with either Native ads provider or Stream adapter

    Native ads provider

    AdUnitId for testing (like for native ad): "7f900c7d-7ce3-4190-8e93-310053e70ca2"

    Native ads provider is more flexible approach to add rendered native ads for UITableView or UICollectionView instead of the complex Stream Adapter classes (AVOTableViewStreamAdapter or AVOCollectionViewStreamAdapter).

    To simplify integration for both Stream Adapter and Native Ads Provider you can use our customizable templates: ListFeedGrid and GridIcon based on AVONativeAdsTemplateTypeenum.

    To create AVONativeAdsProvider object use this method:

    #import <avocarrotnativeview avocarrotnativeview.h="">
              ...
              - (AVONativeAdsProvider *_Nonnull)createNativeAdsProviderForAdunit:(NSString *_Nonnull)adUnitId
                                                                    templateType:(AVONativeAdsTemplateType)templateType
                                                                        userData:(NSDictionary <nsstring *,="" id=""> * _Nullable)userData
                                                           templateCustomization:(void (^ _Nullable)(AVOTemplateCustomizationObject *_Nonnull templateCustomizationObject))templateCustomization;</nsstring></avocarrotnativeview>
              
    import AvocarrotNativeView
              ...
              func createNativeAdsProvider(forAdunit adUnitId: String,
                                           templateType: AVONativeAdsTemplateType,
                                           userData: [String: id]?,
                                           templateCustomization: ((_ templateCustomizationObject: AVOTemplateCustomizationObject) -> Void)? = nil) -> AVONativeAdsProvider

    List of available template customizations is here.

    Also if you want to use your own representation of a native ad, use this method:

    #import <avocarrotnativeview avocarrotnativeview.h="">
              ...
              - (AVONativeAdsProvider *_Nonnull)createNativeAdsProviderForAdunit:(NSString *_Nonnull)adUnitId
                                                         adViewClassForRendering:(Class _Nonnull)adViewClass
                                                                        userData:(NSDictionary <nsstring *,="" id=""> * _Nullable)userData;</nsstring></avocarrotnativeview>
              
    import AvocarrotNativeView
              ...
              func createNativeAdsProvider(forAdunit adUnitId: String,
                                           adViewClassForRendering adViewClass: AnyClass,
                                           userData: [String: id]?) -> AVONativeAdsProvider;
              

    After creating AVONativeAdsProvider object you have to preload need amount of ads by using this method of AVONativeAdsProvider:

    #import <avocarrotnativeview avocarrotnativeview.h="">
              ...
              - (void)preloadAdsInCache:(NSUInteger)preloadCount
                   parentViewController:(UIViewController *_Nonnull)viewController
                                didLoad:(void (^ _Nullable)(NSUInteger preloadCount))successBlock
                                didFail:(void (^ _Nullable)(AVOError *_Nonnull error))errorBlock;
              
    import AvocarrotNativeView
              ...
              func preloadAds(inCache preloadCount: Int,
                              parentViewController viewController: UIViewController,
                              didLoad successBlock: ((_ preloadCount: Int) -> Void)? = nil,
                              didFail errorBlock: ((_ error: AVOError) -> Void)? = nil)

    After getting success callback you are able to get rendered native ads from yourAVONativeAdsProvider object by using this method:

    #import <avocarrotnativeview avocarrotnativeview.h="">
              ...
              - (AVONativeView* _Nullable)getNextAdView;
              
    import AvocarrotNativeView
              ...
              func getNextAdView() -> AVONativeView?
    Note: This method gets next native ad from the ring cache. Each ad will be inserted repeatedly every ‘preloadCount’ interval until it’s tapped or impression is counted and as result ad is automatically replaced with a new one.


    Stream adapter

    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="">
              ...
              - (void)createStreamAdapterForTableView:(UITableView *_Nonnull)tableView
                                 parentViewController:(UIViewController *_Nonnull)viewController
                                             adUnitId:(NSString *_Nonnull)adUnitId
                                         templateType:(AVONativeAdsTemplateType)templateType
                                             delegate:(id <avotableviewstreamadapterdelegate> _Nullable)delegate
                                templateCustomization:(void (^ _Nullable)(AVOTemplateCustomizationObject *_Nonnull templateCustomizationObject))templateCustomization
                                              success:(void (^ _Nullable)(AVOTableViewStreamAdapter *_Nonnull streamAdapter))success
                                              failure:(void (^ _Nullable)(AVOError *_Nonnull error))failure;
              - (void)createStreamAdapterForCollectionView:(UICollectionView *_Nonnull)collectionView
                                      parentViewController:(UIViewController *_Nonnull)viewController
                                                  adUnitId:(NSString *_Nonnull)adUnitId
                                              templateType:(AVONativeAdsTemplateType)templateType
                                                  delegate:(id <avocollectionviewstreamadapterdelegate> _Nullable)delegate
                                     templateCustomization:(void (^ _Nullable)(AVOTemplateCustomizationObject *_Nonnull templateCustomizationObject))templateCustomization
                                                   success:(void (^ _Nullable)(AVOCollectionViewStreamAdapter *_Nonnull streamAdapter))success
                                                   failure:(void (^ _Nullable)(AVOError *_Nonnull error))failure;</avocollectionviewstreamadapterdelegate></avotableviewstreamadapterdelegate></avocarrotnativeview>
              
    import AvocarrotNativeView
              ...
              func createStreamAdapter(for tableView: UITableView,
                                       parentViewController viewController: UIViewController,
                                       adUnitId: String,
                                       templateType: AVONativeAdsTemplateType,
                                       delegate: AVOTableViewStreamAdapterDelegate?,
                                       templateCustomization: ((AVOTemplateCustomizationObject) -> ())?,
                                       success:((AVOTableViewStreamAdapterDelegate) -> ())?,
                                       failure:((AVOError) -> ())?)
              func createStreamAdapter(for collectionView: UICollectionView,
                                       parentViewController viewController: UIViewController,
                                       adUnitId: String,
                                       templateType: AVONativeAdsTemplateType,
                                       delegate: AVOCollectionViewStreamAdapterDelegate?,
                                       templateCustomization: ((AVOTemplateCustomizationObject) -> ())?,
                                       success:((AVOCollectionViewStreamAdapter) -> ())?,
                                       failure:((AVOError) -> ())?)
              
  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.

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 Glispa Connect's policies to use live ads during development, and doing so could get your Glispa Connect's 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?