iOS Ad Formats

Banner/MREC Ads Interstitial Ads Rewarded Ads All-in-One

Integrating Banner/MREC Ads

Before continuing, ensure you have integrated the IASDKCore module here.

Importing the SDK

  1. Import the following IASDK module into your desired view controller:
#import <IASDKCore/IASDKCore.h>

Adding Properties

  1. Each IASDK module should be retained by the “client side”, hence their properties should be added. For example:
@property (nonatomic, strong) IAAdSpot *adSpot;
@property (nonatomic, strong) IAViewUnitController*viewUnitController;
@property (nonatomic, strong) IAMRAIDContentController*mraidContentController;
  1. Create the user data object for better ad targeting:
IAUserData *userData =
[IAUserData build:^(id  _Nonnull builder) { 
    builder.age = 34;     
    builder.gender = IAUserGenderTypeMale;    
    builder.zipCode = @"90210";
IASDKCore.sharedInstance.userData = userData;

The initialization is performed via builder block, that the block runs on the same thread that 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.

Creating the Keywords Object

IASDKCore.sharedInstance.keywords = "swimming, music";

Creating the Ad Request Object

  1. The ad request object initialization:
IAAdRequest *adRequest =
[IAAdRequest build:^(id  _Nonnull builder) { 
    builder.useSecureConnections = NO;    
    builder.spotID = @"YOUR SPOT ID";    
    builder.timeout = 10; 

To send secure requests only, set useSecureConnections to YES

Initializing the MRAID Content Controller

IAMRAIDContentController *mraidContentController =
[IAMRAIDContentController build: ^(id<IAMRAIDContentControllerBuilderh>  _Nonnull builder) {
   builder.MRAIDContentDelegate = self; // A delegate should be passed in order to get video content related callbacks;
self.mraidContentController = mraidContentController; // The MRAID Content ControllerPage should be retained by a client side;

Declaring Your View Controller

  1. Declare your view controller as conforming to IAMRAIDContentDelegate protocol:
@interface YourViewController () <IAMRAIDContentDelegate>

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

Initializing the View Unit Controller

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

self.viewUnitController = viewUnitController; // the View Unit Controller should be retained by a client side;

Declaring Your View Controller

  1. Declare your view controller as conforming to IAUnitDelegate protocol:
@interface YourViewController () <IAUnitDelegate, IAMRAIDContentDelegate>

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

Initializing the Placement (previously known as Ad Spot)

  1. Initialize your Placement:
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;

Fetching the Ad

  1. Fetch 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 Banner/MREC Ads!

Back to Top ⇧