Integrating Video Ads


Before continuing, please ensure you have integrated the IASDKCore and IASDKVideo modules here.

Integrating Video Ads

  1. Import the following required IASDK modules into your desired view controller:
Importing the IASDK Module
#import <IASDKCore/IASDKCore.h>
#import <IASDKVideo/IASDKVideo.h>
  1. Each IASDK module should be retained by the “client side”, hence their properties should be added. For example:

Adding Properties

@property (nonatomic, strong) IAAdSpot *adSpot;
@property (nonatomic, strong) IAViewUnitController *viewUnitController;
@property (nonatomic, strong) IAVideoContentController *videoContentController;
  1. Create the user data object for better ad targeting:

Creating the User Data Object

IAUserData *userData =
[IAUserData build:^(id<IAUserDataBuilder>  _Nonnull builder) { 
    builder.age = 34;     
    builder.gender = IAUserGenderTypeMale;    
    builder.zipCode = @"90210";


The initialization is performed via builder block - the block runs on the same thread as it is invoked from, and is synchronous (like the enumerateObjectsUsingBlock iOS method).

As a result, the special block treatment (such as weak references, etc...) is not needed.

  1. Next comes the ad request object initialization:

Adding the Ad Request Object

IAAdRequest *adRequest =
[IAAdRequest build:^(id<IAAdRequestBuilder>  _Nonnull builder) { 
    builder.userData = userData; // pass here the user data object, if relevant;
    builder.useSecureConnections = NO;    
    builder.spotID = @"YOUR SPOT ID";    
    builder.timeout = 10;    
    builder.keywords = @"books, music";    
    builder.autoLocationUpdateEnabled = YES;
    // builder.muteAudio = YES; // will start a non-rewarded video in mute state

- IAAdRequest Class


To send secure requests only, please set useSecureConnections to YES

  1. Initialize your Video Content Controller:

Initializing the Video Content Controller

IAVideoContentController *videoContentController =
[IAVideoContentController build: 
  ^(id<IAVideoContentControllerBuilder>  _Nonnull builder) {
   builder.videoContentDelegate = self; // a delegate should be passed in order to get video content related callbacks;

self.videoContentController = videoContentController; // the Video Content ControllerPage should be retained by a client side;
  1. Declare your view controller as conforming to IAVideoContentDelegate protocol:

Declaring your View Controller

@interface YourViewController () <IAVideoContentDelegate>


Refer to this page for a full explanation of Video Content Delegate Protocol.

  1. Initialize the View Unit Controller:

Initializing the View Unit Controller

IAViewUnitController *viewUnitController =
[IAViewUnitController build:^(id<IAViewUnitControllerBuilder>  _Nonnull builder) {
    builder.unitDelegate = self;
    // all the needed content controllers should be added to the desired unit controller:    
    [builder addSupportedContentController:self.videoContentController];

self.viewUnitController = viewUnitController; // the View Unit Controller should be retained by a client side;
  1. Declare your view controller as conforming to IAUnitDelegate protocol:
Declaring your View Controller
@interface YourViewController () <IAUnitDelegate, IAVideoContentDelegate>


Refer to this page for a full explanation of Unit Delegate Protocol.

  1. Initialize your Ad Spot:

Initializing your Ad Spot

IAAdSpot *adSpot = [IAAdSpot build:^(id<IAAdSpotBuilder>  _Nonnull builder) {
    builder.adRequest = adRequest; // pass here the ad request object;    
    // all the supported (by a client side) unit controllers,
    // (in this case - view unit controller) should be added to the desired ad spot:     
    [builder addSupportedUnitController:self.viewUnitController];

self.adSpot = adSpot; // the Ad Spot should be retained by a client side;
  1. Fetch the ad:

Fetching the Ad

// declare a weak property, because of block:
__weak typeof(self) weakSelf = self;

[self.adSpot fetchAdWithCompletion:^(IAAdSpot * _Nullable adSpot, IAAdModel * _Nullable adModel, NSError * _Nullable error) {    
  if (error) {        
    NSLog(@"Failed to get an ad: %@\n", error);    
  } else {        
    if (adSpot.activeUnitController == weakSelf.viewUnitController) {
      [weakSelf.viewUnitController showAdInParentView:weakSelf.view];        

You have now finished integrating Video Ads!

You can now begin to integrate other ad types: