IOS SDK Integration

iOS SDK for in-app advertising with Collectcent SSP

This is a free Software Development Kit for the iOS application developers and publishers to monetize digital mobile inventory faster than the blink of an eye. Collectcent integrates with Collectcent SSP, one single source of offerings tailored to publishers' needs.

Supported Ad formats

CollectcentAdsSDK supports five Banner Sizes. Your should choose size to pass in initialization( your_banner_size_here) accordingly to selected placement type on SSP platform:

Banner and rich media ads:

Size, DPI Type CollectcentAdsSDK Size Constant
320x50 Standard Banner kCollectcentAdSizeBanner
320x100 Large Banner kCollectcentAdSizeLargeBanner
300x250 IAB Medium Rectangle kCollectcentAdSizeIABMediumRectangle
468x60 IAB Full-Size Banner kCollectcentAdSizeIABFullSizeBanner
728x90 IAB Leaderboard kCollectcentAdSizeIABLeaderBoard

Video ads:

Orientation: Landscape or Portrait

In accordance with the IAB specification:

Interstitial ads:

Size, DPI Type
Custom size Full screen

Getting Started

Just a few steps to start (to understand how user works with inventory):

  1. Register your account on Collectcent Supply Side Platform

  2. Confirm your registration by following the confirmation link sent via email

  3. Create your first mobile inventory by clicking Add Inventory. Select iOS Application in pop up.

  4. Fill all required fields in Add Inventory form. Inventory should be reviewed and approved before presenting ads. Click Save changes for proceeding next

    Add Inventory
  5. After this, you will be granted access to create placements for your inventory, +Banner button should become clickable

    Add Inventory Summaryt
  6. Click on +Banner, add the targeting options, floor price and size of your placement, then click Save changes

    Add Placement
  7. Please, note the Placement ID(e.g., ID#5884) below it's title. It will be used later in your code to initialize the ad container

    Placement Summary

Requirements

CollectcentAdsSDK iOS in-app advertising framework requires iOS 8 and up .

Installation

  • Download CollectcentAdsSDK Cocoa Touch framework

  • Place CollectcentAdsSDK.framework in project's folder

  • In Xcode, choose your App Target: General -> Embedded Binaries -> Add CollectcentAdsSDK.framework from the folder where it was placed on the previous step

  • In Xcode, choose your App Target:Build Settings -> Architectures -> Build Active Architecture Only set YES

  • In Xcode, choose your App Target:Build Settings -> Build Options -> Enable Bitcode set NO

Setup App Permissions

  • Edit your Info.plist file to include the following properties: * Add CollectcentBundleIsPaid property and its Boolean value: - YES - if your App is paid, or you have in-app purchases - NO - if your App is distributed free of any charges

    SMABundleIsPaid
  • OPTIONAL Add Privacy - Location When In Use Usage Description property with a String value: CollectcentAdsSDK and/or the SDKs mediated by Collectcent would like to access your location information to allow CollectcentAdsSDK use Device location for geo ad targeting:

    • IN Xcode:

      Location When In Use Description
    • OR by opening Info.plist and adding following properties:

          <?xml version="1.0" encoding="utf-8"?>
          <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">
            <plist version="1.0">
                <dict>
                  ...
                  <key>nslocationwheninuseusagedescription</key>
                  <string>CollectcentAdsSDK and/or the sdks mediated by Collectcent would like to access your location information.</string>
                  ...
                </dict>
            </plist>
                                              
  • Turn on App Transport Security flag. This is needed for receiving Ad View content via HTTP protocol. Although this step is not required, without it, you won't be able to receive Ad View content from advertisers which use HTTP references for resources in its content:

    • TURN ON App Transport Security - Allows Arbitrary Loads property - this option will allow ad content loading via HTTP protocol. In order to turn turn on this property do the following:

      • IN Xcode:

      • OR by opening Info.plist and adding following properties:

            <?xml version="1.0" encoding="utf-8"?>
            <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">
              <plist version="1.0">
                  <dict>
                      ...
                      <key>nsapptransportsecurity</key>
                      <dict>
                      <key>nsallowsarbitraryloads</key>
                      <true/>
                      </dict>
                      ...
                  </dict>
              </plist>
                                                        
    • ALTERNATIVELY, you can use App Transport Security - Allows Arbitrary Loads In Web Content property - this option will allow web content loading via HTTP protocol. Also add publishers.collectcent.com to Exception Domains dictionary:

      • IN Xcode:

        Allow Arbitrary Web Content
      • OR by opening Info.plist and adding following properties:

            <?xml version="1.0" encoding="utf-8"?>
            <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd">
              <plist version="1.0">
                  <dict>
                      ...
                      <key>nsapptransportsecurity</key>
                      <dict>
                          <key>nsexceptiondomains</key>
                      <dict>
                          <key>publishers.collectcent.com</key>
                      <dict/>
                          <key>nsexceptionallowsinsecurehttploads</key>
                          <true/>
                          <key>nsincludessubdomains</key>
                          <true/>
                      </dict>
                      <key>nsallowsarbitraryloadsinwebcontent</key>
                      <true/>
                      ...
                  </dict>
              </plist>
                                                        

Initializing CollectcentAdsSDK

In AppDelegate.m, -application:didFinishLaunchingWithOptions: method add following initializing code:

    #import <CollectcentAdsSDK/CollectcentAdsSDK.h>

    ...

    - (BOOL)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions
    {
        [CollectcentAds start];
        [CollectcentAds GDPRconsentFlag:YES];

        return YES;
    }
                        

Setting GDPR (Requirement)

To make your iOS SDK GDPR compliant please set one of the following options:
  + (void)GDPRconsentFlag:(BOOL)flag; - set a new value for GDPR user consent. GDPR user consent is a boolean value, where YES = user consent given & NO = user consent denied or no information provided.

  + (BOOL)getGDPRconsentFlag; - get current GDPR value
                        

Add Banner

In View/ ViewController where you want to show Banner, add CollectcentBannerAdView property as a class var:

    #import <CollectcentAdsSDK/CollectcentAdsSDK.h>

    @interface ViewController ()<CollectcentBannerAdViewDelegate>
    @property (nonatomic, strong) CollectcentBannerAdView *adview;

    @end
                        

Use -init, -initWithFrame:, or -viewDidLoad as a place for adView initialization:

    - (instancetype)init {
        self = [super init];
        self.adView = [[CollectcentBannerAdView alloc] initWithPlacementId:**your_banner_id_here** size:**your_banner_size_here**];
        self.adView.delegate = self;
        [self.view addsubview:self.adview];
        return self;
    }
                        

Important

Do not forget to replace the your_banner_id_here with the placement ID from the Platform(Step 6 of the Getting Started section, e.g. @"5884") and your_banner_size_here (e.g. kCollectcentAdSizeBanner) accordingly. See the sample code below:

    [[CollectcentBannerAdView alloc] initWithPlacementId:**your_banner_id_here** size:**your_banner_size_here**];
                        

Driving CollectcentBannerAdView

CollectcentBannerAdView serves the following methods for Ad View management:

  • -loadBannerAd - loads Banner Ad from server to local cache

  • -showBannerAdView - shows Banner Ad View from local cache

  • -forceRefreshAd: - cancels current load and refreshes Ad View

  • -startAutomaticallyRefreshingContents - starts refreshing Ad View periodically. Minimal refresh interval is 30 seconds. You can set new interval in method -autoRefreshInterval

  • -stopAutomaticallyRefreshingContents - stops previously initiated auto refresh process

Driving CollectcentBannerAdViewDelegate

Required methods:
  • -bannerAdDidLoad - fires when Banner AD is successfully loaded and ready for showing

  • -bannerAdDidFailLoadingWithError: - fires when Banner Ad failed to load from server

  • -bannerAdCacheDidFailLoadingWithError: - fires when Banner Ad failed to load from local cache

Optional methods:
  • -bannerAdViewDidAppear - fires when Banner Ad View appear on View Controller

  • -bannerAdViewDidDisappear - fires when Banner Ad View disappear from View Controller

  • -bannerAdViewClicked - fires when user clicked on Banner Ad View

  • -shouldRequestPreciseLocation - asks if Ad View can request geo location, by using device location services, YES by default

  • -autoRefreshInterval - method for overriding time interval for auto refreshing

Add Video Ad

In ViewController where you want to show Video, add CollectcentVideoAdController property.

    #import <CollectcentAdsSDK/CollectcentAdsSDK.h>

    @interface ViewController () <CollectcentVideoAdDelegate>

    @property (nonatomic, strong) CollectcentVideoAdController *videoAd;

    @end
                    

Use -viewDidLoad, -init as a place for adVideo initialization:

    - (void)viewDidLoad {
        [super viewDidLoad];

        self.videoAd = [[CollectcentVideoAdController alloc] initWithPlacementId:**your_video_id_here**];
        self.videoAd.delegate = self;
    }
                    

Important

Don't use -viewDidAppear:, -viewWillAppear: methods for initialization CollectcentVideoAdController

Video Ad Load and Presentation

In order to load Video Ad, you should call -loadVideoAd method.

    - (void)somemethod {
        ...your code there...

        [self.videoAd loadVideoAd];
    }
                    

For shows Video Ad View just call -showVideoAd method.

    - (void)videoAdDidLoad {
        [self.videoAd showVideoAd];
    }
                  

Driving CollectcentVideoAdViewDelegate

Required methods:
  • -videoAdDidLoad - fires when Video Ad is successfully loaded

  • -videoAdDidFailLoadingWithError: - fires when Video Ad failed to load from server

  • -videoAdCacheDidFailLoadingWithError: - fires when Video Ad failed to load from local cache

Optional methods:
  • -videoAdViewDidAppear - fires when Video Ad View appear on View Controller

  • -videoAdViewDidDisappear - fires when Video Ad View disappear from View Controller

Additional params

  • rewardMacros - set this property if you set reward params in your inventory

  • amountMacros - set this property if you set amount params in your inventory

Add Interstitial Ad

In ViewController where you want to show Interstitial, add CollectcentInterstitialAdViewController property:

    #import <CollectcentAdsSDK/CollectcentAdsSDK.h>

    @interface ViewController ()<CollectcentInterstitialAdDelegate>

    @property (nonatomic, strong) CollectcentInterstitialAdViewController *interstitialad;

    @end
                  

Use -init, -viewDidLoad as a place for interstitialAd initialization:

    - (void)viewDidLoad {
        [super viewDidLoad];

        self.interstitialAd = [[CollectcentInterstitialAdViewController alloc] initWithPlacementId:**your_interstitial_id_here**];
        self.interstitialAd.delegate = self;
    }
                    

Important

Don't use -viewDidAppear:, -viewWillAppear: methods for initialization CollectcentInterstitialAdViewController

Interstitial Ad Load and Presentation

In order to load Interstitial Ad, you should call -loadInterstitialAd method.

    - (void)someMethod {
        ...your code there...

        [self.interstitialAd loadInterstitialAd];
    }
                    

For shows Interstitial Ad View just call -showInterstitialAd method.

    - (void)interstitialAdDidLoad {
        [self.interstitialAd showinterstitial];
    }
                    

Driving CollectcentInterstitialAdViewDelegate

Required methods:
  • -interstitialAdDidLoad - fires when Interstitial Ad is successfully loaded

  • -interstitialAdDidFailLoadingWithError: - fires when Interstitial Ad failed to load from server

  • -interstitialAdCacheDidFailLoadingWithError: - fires when Interstitial Ad failed to load from local cache

Optional methods:
  • -interstitialAdViewDidAppear - fires when Interstitial Ad View appear on View Controller

  • -interstitialAdViewDidDisappear - fires when Interstitial Ad View disappear from View Controller